微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SPM 包找不到导入 SwiftUI 我已经我的项目

如何解决SPM 包找不到导入 SwiftUI 我已经我的项目

我在我的项目中使用了我自己制作的 Swift Package Manager 数据包 (Here is the Github Link),我测试了该数据包,它确实可以正常工作,并且已经运行了几天,但是当我尝试存档应用程序将其发布到 TestFlight 它开始显示这些对我没有任何意义的错误

enter image description here

我已经

我的项目

  • 使用 iOS14
  • 有目标设置为 iOS14 的 Pods
  • 使用 SwiftUI

解决方法

结果我必须指定支持 SwiftUI 的 iOS、TvOS、watchOS 和 macOS 版本,在我的情况下,我主要使用每个平台的最新版本,因为我的库需要它,但对于 SwiftUI 是最早支持的版本是iOS13

let package = Package(
    name: "SwiftUISnackbar",platforms: [
            .macOS(.v11),.iOS(.v14),.tvOS(.v14),.watchOS(.v7)
        ],products: [
        // Products define the executables and libraries a package produces,and make them visible to other packages.
        .library(
            name: "SwiftUISnackbar",targets: ["SwiftUISnackbar"]),],dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */,from: "1.0.0"),targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package,and on products in packages this package depends on.
        .target(
            name: "SwiftUISnackbar",dependencies: []),.testTarget(
            name: "SwiftUISnackbarTests",dependencies: ["SwiftUISnackbar"]),]
)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。