在具有 iOS 部署目标 14.5 的 Xcode 12.5 中,我想导入 swift-collections
库以使用模块 OrderedDictionary
。
当我添加以下 URL https://developer.apple.com/swift/packages/collections/apple.json
作为包存储库时,我收到以下错误:
我认为这是一个授权问题。我应该在哪里输入我的凭据?
最佳答案
Swift 5.5 和 Xcode 13+
Package Collections 在 Swift 5.5 和 Xcode 13 中引入。
来自 Swift.org
You can add it using the new package-collection add option from the SwiftPM command line
$ swift package-collection add https://developer.apple.com/swift/packages/collections/apple.json
执行上述命令后,在 Xcode 项目导航器中选择您的项目,在项目和目标列表中再次选择它,然后切换到 Swift Packages 选项卡并单击 Packages 列表下方的 + 按钮,您将看到收藏列表。并从列表中添加 swift-collections 包。
注意:确保您至少安装了 Swift 5.5。您可以使用 swift --version
检查正在运行的 Swift 版本。
低于 Xcode 13
有效的 URL 是:https://github.com/apple/swift-collections
您必须添加 swift 集合包而不是 json。
检查来自 here 的 Using Swift Collections in your project
部分
安装后,您将获得以下用于选择目标的选项卡。并选择 OrderedCollections 目标。
文档: https://github.com/apple/swift-collections/blob/main/Documentation/OrderedDictionary.md
关于swift - 如何将包集合添加到我的 Xcode 项目中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67946327/