swift - 如何将包集合添加到我的 Xcode 项目中?

标签 swift xcode package

在具有 iOS 部署目标 14.5 的 Xcode 12.5 中,我想导入 swift-collections 库以使用模块 OrderedDictionary

当我添加以下 URL https://developer.apple.com/swift/packages/collections/apple.json 作为包存储库时,我收到以下错误:

enter image description here

我认为这是一个授权问题。我应该在哪里输入我的凭据?

最佳答案

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 包。

enter image description here

注意:确保您至少安装了 Swift 5.5。您可以使用 swift --version 检查正在运行的 Swift 版本。

低于 Xcode 13

有效的 URL 是:https://github.com/apple/swift-collections

您必须添加 swift 集合包而不是 json。

检查来自 hereUsing Swift Collections in your project 部分

安装后,您将获得以下用于选择目标的选项卡。并选择 OrderedCollections 目标。

文档: https://github.com/apple/swift-collections/blob/main/Documentation/OrderedDictionary.md

enter image description here

关于swift - 如何将包集合添加到我的 Xcode 项目中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67946327/

相关文章:

ios - "nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection"导致搜索栏出现问题

linux - debian 包装 : what's the difference between dh build and dh binary

r - 如何处理导入包 (`Depends:` ) 的依赖关系 (`Imports:` )

swift - 在 UITableViewCell 中按下按钮后获取 NSManagedObject 的一个属性

ios - 在 Swift 中初始化 Parse.com TableView Controller

xcode - 阿拉伯语 NSString 显示 Xcode 调试器和日志之间不同的字母顺序

ios - 当 slider 按钮超过最大值的大约 60% 时,UISlider 最大轨道图像使用最小轨道图像

java - 源文件夹不在 Java 构建类路径上,正在创建 Java 包

ios - 修复github项目SwiftChart中的错误

ios - self.tableView 为零,与调用 numberOfSections TableView 的 uitableview 不同