导入我创建的库时遇到问题。
这是Package.swift
的{{1}}:
executable
当我在import PackageDescription
let package = Package(
name: "PayBackCodingChallenge",
dependencies: [
.package(url: "../NumberChecker", from: "1.0.0"),
],
targets: [
.target(
name: "PayBackCodingChallenge",
dependencies: []),
]
)
尝试import NumberChecker
时,我收到以下消息:没有这样的模块'NumberChecker':
main.swift
我的NumberChecker库位于与PayBackCodingChallenge相同级别的目录中并正确编译。可能是什么问题?
提前致谢!
答案 0 :(得分:2)
您应该将NumberChecker
作为依赖项添加到PayBackCodingChallenge
:
...
targets: [
.target(
name: "PayBackCodingChallenge",
dependencies: ["NumberChecker"]),
]
...