问题描述
我正在 Xcode 中处理一个项目,并尝试安装和使用 CryptoSwift 包通过 Swift 包管理器.
I'm working on a project in Xcode and am attempting to install and use the CryptoSwift package via the Swift Package Manager.
我阅读了 SPM 上的文档,但没有看到说明关于如何通过 Xcode 调用 SPM.
I read the documentation on SPM, but I don't see instructions on how to invoke the SPM through Xcode.
这些例子通常是指调用$ swift build
.这是否意味着只能从命令行访问 SPM?如果是这样,我应该在哪里创建 Package.swift
文件?
The examples often refer to calling $ swift build
. Does this mean that the SPM is only accessible from the command line?And if so, where exactly am I supposed to create the Package.swift
file?
我对 Xcode 相当熟悉,但我不太了解项目的构建设置部分的含义,或者如何使用 Swift 模块.
I'm reasonably familiar with Xcode, but I don't really understand the meaning of the build settings part of a project, or how Swift modules are used.
这个问题最初是针对 Swift 2.1.1 附带的 Xcode 7.2 提出的.很乐意接受解释如何使用当前/未来版本的 Xcode 执行此操作的答案.
This question was originally asked for Xcode 7.2, which shipped with Swift 2.1.1. Will gladly accept answers that explain how to do this with current/future versions of Xcode.
推荐答案
Swift Package Manager 现在支持使用
Swift Package Manager now support generating Xcode project with
swift package generate-xcodeproj
如此答案中所述,但这仅在开发库或命令行工具时有效.不适用于(iOS/OS X)图形应用程序开发人员:
as mentioned in this answer, but this only works when developing a library, or a command line tool. Not (yet) for (iOS/OS X) graphical application developer:
请注意,目前包管理器不支持 iOS、watchOS 或 tvOS 平台.
注意:
- 如果您的软件包名称中有空格,则可能无法正常工作,即将App Store"更改为AppStore".
这篇关于如何通过 Swift 包管理器在 Xcode 中安装包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!