没有这样的模块“PackageDescription” [英] No such module "PackageDescription"
问题描述
我刚开始使用swift 3并使用Swift 3.0在xcode中创建了一个简单的应用程序。现在我想使用Swift Package Manager添加第三方库。我正在按照此链接中给出的安装方法。我创建了 Package.swift
文件,看起来像这样
I just started with swift 3 and made a simple app in xcode using Swift 3.0 . Now i want to add a third party library using Swift Package Manager . I am following installation method given in this link . I created Package.swift
file which looks like this
import PackageDescription
let package = Package (
name : "SwiftPM",
dependencies : [
.Package(url: "https://github.com/ArtSabintsev/Siren.git", majorVersion: 1)
])
但我收到错误没有这样的模块PackageDescription
推荐答案
Swift包管理器和Xcode是正交的。也就是说,你不能指望在Xcode中编译Package.swift;它根本行不通。相反,在Xcode支持包管理器之前,您需要有两个不同的构建 - 一个使用包管理器,另一个使用Xcode。
The Swift Package Manager and Xcode are orthogonal. That is, you can't expect to compile Package.swift in Xcode; it simply won't work. Instead, until Xcode supports the package manager, you need to have two distinct builds - one with the package manager and one with Xcode.
因此,使用Swift包管理器,一旦你定义了Package.swift并按照包管理器的要求制定了你的目录结构,你只需执行:
So, using the Swift Package Manager, once you've defined Package.swift and formulated your directory structure as expected by the package manger, you perform simply:
swift build
然后对于Xcode,您创建一个使用源代码但不使用Package.swift的Xcode项目。您需要将Siren.git项目明确地克隆到Xcode构建的源文件中。
Then for Xcode, you create an Xcode project that uses your source code, but not Package.swift. You'll need to clone the Siren.git project, explicitly - into your Xcode build's source files.
这篇关于没有这样的模块“PackageDescription”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!