Ios 为什么可以';我是否将SPM实用程序库作为依赖项包含在我的Package.swift中?
我想在我的项目中包括的实用程序库(SPM) 特定库在SPM的Ios 为什么可以';我是否将SPM实用程序库作为依赖项包含在我的Package.swift中?,ios,swift,macos,Ios,Swift,Macos,我想在我的项目中包括的实用程序库(SPM) 特定库在SPM的包中定义。swift如下: ... .library( name: "TSCUtility", targets: [ "TSCclibc", "TSCLibc", "TSCBasic", "TSCUtility", ] ), ... // swift-tools-v
包中定义。swift
如下:
...
.library(
name: "TSCUtility",
targets: [
"TSCclibc",
"TSCLibc",
"TSCBasic",
"TSCUtility",
]
),
...
// 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"]),
]
)
当我构建项目时,出现以下错误:
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
,那么一切正常吗
My Package.swift的定义如下:
...
.library(
name: "TSCUtility",
targets: [
"TSCclibc",
"TSCLibc",
"TSCBasic",
"TSCUtility",
]
),
...
// 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,其中实用程序库仍然命名为
spmultility
。您可以通过声明对master
分支的依赖关系来获取最新版本:
依赖项:[
.package(url:)https://github.com/apple/swift-package-manager.git“,.分公司(“主分公司”))
],
谢谢。因此,.branch
针对的是一个特定的分支,其中as.from
只针对标记版本,即具有指定标记的提交(每个提交可能没有标记)-我说得对吗?:-)