在 Package.swift 中,将目标添加到库中的目标数组与将目标添加到依赖项数组之间有什么区别。
在第一个示例中,将“Helpers”作为依赖项添加到“MySwiftPackage”目标。
let package = Package(
name: "MyTestPackage",
products: [
.library(
name: "MyTestPackage",
targets: ["MyTestPackage"]),
.library(
name: "Helper",
targets: ["Helper"]),
],
dependencies: [
],
targets: [
.target(
name: "MyTestPackage",
dependencies: ["Helper"]), // <---- 'Helper' defined as dependency
.target(
name: "Helper",
dependencies: []),
]
)
在下一个示例中,“Helper”被添加为“MySwiftPackage”库中的另一个目标。
let package = Package(
name: "MyTestPackage",
products: [
.library(
name: "MyTestPackage",
targets: ["MyTestPackage","Helper",]), // <-- 'Helper' defined in targets
.library(
name: "Helper",
targets: ["Helper"]),
],
dependencies: [
],
targets: [
.target(
name: "MyTestPackage",
dependencies: []),
.target(
name: "Helper",
dependencies: []),
]
)
据我所知,这两个选项会产生相同的结果:当我将 MySwiftPackage 声明为 Xcode 项目中的依赖项时,我可以同时导入“MySwiftPackage”模块和“Helper”模块。
除了放置“Helper”的位置之外,这两个清单文件之间是否存在显着差异?