尝试在我的机器上使用 Xcode-beta (v9) 测试 Swift 4,但在将包导入测试项目时遇到问题:
- 启动项目使用
swift package init --type executable
- Changed
Package.swift
并添加了 2 个项目来尝试:
包.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: []),
]
)
- Run
swift build && swift package generate-xcodeproj
- 当我在 Xcode-beta(v9) 中打开项目并尝试导入 Kitura 或 Alamofire 时,我得到
No such module Kitura/Alamofire
错误信息
- Running
swift build
在终端中产生以下错误:
编译 Swift 模块“investprosto”(1 个来源)
/Users/用户名/Projects/sampleproject/Sources/sampleproject/main.swift:1:8:
错误:没有这样的模块“Kitura”导入 Kitura
^ 错误:终止(1):/Applications/Xcode- beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-
构建工具-f /Users/用户名/Projects/sampleproject/.build/debug.yaml
依赖关系虚拟文件夹包含具有相同包名称的目录,但它们是空的。然而,.build\checkouts
and .build\repositories
包含包文件夹和相应的文件。
我的系统配置中是否缺少某些内容?
结果我还必须将依赖项包含到.target
Package.swift的:
.target(named: "sampleproject", dependencies: ["Kitura", "Alamofire"])
并再次构建项目。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)