关于Swift Package Manager,如何使用本地库包作为没有git存储库的可执行包的依赖项? SwiftPM声称它允许您在url字段中传入本地路径,但随后抱怨它无法克隆存储库。
来自Package.swift的
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "../../../string-calculator/swift/StringCalculator", from: "1.0.0"),
],
运行swift package update
时,我得到以下输出:
Fetching /Users/tsd037/Documents/Workspace/Misc/tdd-kata/string-calculator/swift/StringCalculator
error: failed to clone; fatal: repository '/Users/tsd037/Documents/Workspace/Misc/tdd-kata/string-calculator/swift/StringCalculator' does not exist
答案 0 :(得分:0)
请注意,即使对于本地目录,您也必须创建一个git存储库(本地)。只需在本地目录git init
中运行git commit
并添加标记,例如git tag 1.0.0
。
答案 1 :(得分:0)
遇到了同样的问题,在 API 文档中找到了以下解决方案。
https://developer.apple.com/documentation/swift_packages/package/3583304-init https://developer.apple.com/documentation/swift_packages/package/dependency/3582846-package
使用“path”参数代替“url”
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(path: "../../../string-calculator/swift/StringCalculator"),
],