Can';t使用Swift 4软件包管理器导入软件包
试图在我的机器上使用Xcode beta(v9)测试Swift 4,但在将包导入测试项目时遇到问题:Can';t使用Swift 4软件包管理器导入软件包,swift,xcode,macos,package-managers,swift4,Swift,Xcode,Macos,Package Managers,Swift4,试图在我的机器上使用Xcode beta(v9)测试Swift 4,但在将包导入测试项目时遇到问题: 使用swift package init--type executable启动项目 更改了软件包。swift并添加了两个要试用的项目: 包装。swift // swift-tools-version:4.0 // The swift-tools-version declares the minimum version of Swift required to build this packa
- 使用
swift package init--type executable启动项目
- 更改了
并添加了两个要试用的项目:软件包。swift
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "sampleproject",
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/Kitura.git", from: "1.7.6"),
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.5.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "sampleproject",
dependencies: []),
]
)
- 运行
swift构建和&swift包生成xcodeproj
- 当我在Xcode beta(v9)中打开项目并尝试导入Kitura或Alamofire时,我得到了
错误消息没有这样的模块Kitura/Alamofire
- 在终端中运行
会产生以下错误:swift build
.build\checkout
和.build\repositories
包含包文件夹和相应的文件
我的系统配置中是否缺少一些东西?结果表明,我还必须将依赖项包括在包的
.target
中。swift:
.target(named: "sampleproject", dependencies: ["Kitura", "Alamofire"])
然后重新构建项目。即使您需要将
目标添加到包中。
有时还不够。我已通过删除.build
目录和文件包解决了该问题。解决了,然后运行快速构建
或从Xcode构建。Build命令没有提取包,因为它已经在解析的文件中,但是如果删除.Build
目录,它将变得毫无意义。您可以通过检查Xcode中的依赖项目录来验证它,如果出现类似没有此类包/模块的错误,则该目录将为空。从文件上看这并不明显。然后,似乎必须转到特定包的git repo的URL,才能将其映射到缺少的模块。因为导入名称不一定与包名称相同。