我想在项目中包括Swift Package Manager(SPM)的TSCUtility库。
SPM的Package.swift
中定义了特定的库,如下所示:
...
.library(
name: "TSCUtility",
targets: [
"TSCclibc",
"TSCLibc",
"TSCBasic",
"TSCUtility",
]
),
...
构建项目时,出现以下错误:
swift build --product nfgz
'ngfz' /Users/nlykkei/Projects/ngfz: error: product dependency 'TSCUtility' not found
warning: dependency 'SwiftPM' is not used by any target
提示找不到该库。但是,如果我改为将另一个SPM库作为依赖项,例如
SwiftPM
,那么一切正常吗?我的Package.swift定义如下:
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "ngfz",
products: [
.executable(
name: "ngfz",
targets: ["ngfz"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/apple/swift-package-manager.git", from: "0.1.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: "ngfz",
dependencies: ["TSCUtility"]),
.testTarget(
name: "ngfzTests",
dependencies: ["ngfz"]),
]
)
最佳答案
据我所知,最后标记的版本是0.4.0,其中实用程序库仍命名为SPMUtility
。您可以通过声明对master
分支的依赖来获取最新版本:
dependencies: [
.package(url: "https://github.com/apple/swift-package-manager.git", .branch("master"))
],