swift - SPM - 包包含修改后的依赖项

标签 swift mongodb swift-package-manager

我正在尝试使用 swift 包驱动程序安装 MongoDB swift 驱动程序。我关注了their instructions并使用自制软件安装了 mongo-c-driver。然后我创建了一个新目录并在一个新项目中使用:

swift package init --type executable

然后我将依赖项添加到 Package.swift 文件中。

当尝试在目录中运行任何调用swift package resole 的命令时,出现以下错误:

error: the package PackageReference(identity: "mongo-swift-driver", name: nil, path: "https://github.com/mongodb/mongo-swift-driver.git", isLocal: false) @ 0.0.2 contains revisioned dependencies:

PackageReference(identity: "swift-bson", name: nil, path: "https://github.com/mongodb/swift-bson", isLocal: false) @ master

PackageReference(identity: "swift-mongoc", name: nil, path: "https://github.com/mongodb/swift-mongoc", isLocal: false) @ master

我确保所有内容都是最新的并且 Package.swift 的第一行是 //swift-tools-version:4.0

我想知道这些修订后的依赖项是什么,因为我没有发现任何有用的东西。以及如何解决此错误。

最佳答案

Swift Evolution 提议引入了在 SPM 包中指定分支而不是修订的能力(SE-0150 是这样说的:

While this feature [specifying branches] is useful during development, a package's dependencies should be updated to point at versions instead of branches before that package is tagged for release. This is because a released package should provide a stable specification of its dependencies, and not break when a branch changes over time. To enforce this, it is an error if a package referenced by a version-based dependency specifies a branch in any of its dependencies.

看起来您正在使用的父包版本 0.0.2 没有遵循为其依赖项切换到特定版本的规则,SPM 不允许这样做。

如果可能,您应该尝试使用修复此问题的较新版本的父包。如果不存在较新的版本,您可能必须覆盖依赖项并自己修复它(我相信您可以使用 swift package edit 来做到这一点——或者 fork 依赖项并指向您自己的 repo ,当然。)

关于swift - SPM - 包包含修改后的依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51314502/

相关文章:

swift 包 --verbose generate-xcodeproj 给出错误 : reachedTimeLimit

ios - 是否可以在应用程序图标上显示进度

node.js - 如果字段设置为 null,则恢复为 mongoose 中的默认值

python - 如何从连接 URI 中的 SQL 密码转义 `@` 字母

swift - 无法使用 Swift 包管理器

cocoapods - 导入Swift Package Manager依赖项时出现 'no such module'错误

ios - 如何在 Swift 中使用常量 : AVAudioSessionInterruptionNotification

swift - UISlider,保存状态

json - 在 swift4 中使用未解析的标识符 'json'

node.js - Mongoose 仅​​返回文档的一个属性,而不返回整个文档