gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 01:59:18 25 4
gpt4 key购买 nike

在具有 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com