Vapor中描述依赖包的majorVersion和minor

majorVersion and minor in describing dependency package in Vapor

如何决定在下面的代码中为 majorVersionminor 放置什么。 我试图将 sqlite3 与 vapor 一起使用,但卡在了这里。

import PackageDescription

let package = Package(
    name: "Hello",
    dependencies: [
        .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 1)
        ,.Package(url: "https://github.com/vapor/sqlite-driver.git", majorVersion: 1, minor: 0)
        ,.Package(url: "https://github.com/vapor/sqlite-provider.git", majorVersion: 1, minor: 1)
    ],
    exclude: [
        "Config",
        "Database",
        "Localization",
        "Public",
        "Resources",
        "Tests",
    ]
)

当我执行 vapor build -

时出现如下错误

Fetching Dependencies [Failed] Check your dependencies' Package.swift files to see where the conflict is. Error: swift-package: error: The dependency graph could not be satisfied. The package (https://github.com/vapor/sqlite-driver.git) with version tag in range (1.1.0..<1.1.9223372036854775807) is not found. Found tags ([0.0.0, 0.1.0, 0.1.1, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.4.0, 0.4.1, 0.5.0, 0.6.0, 0.7.0, 1.0.0, 1.0.1])

'dependency graph' 错误与您的一个包相关,具体取决于另一个包的冲突版本。错误消息告诉您 'Check your dependencies' Package.swift 个文件以查看冲突所在。'

您不需要同时包含 sqlite-driversqlite-provider,因为后者已经内置了对前者的依赖。只需从应用的 Package.swift 中删除对 sqlite-driver 的依赖。之后还要确保vapor clean

import PackageDescription

let package = Package(
    name: "Hello",
    dependencies: [
        .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 1),
        .Package(url: "https://github.com/vapor/sqlite-provider.git", majorVersion: 1, minor: 1)
    ],
    exclude: [
        "Config",
        "Database",
        "Localization",
        "Public",
        "Resources",
        "Tests",
    ]
)

注意:Vapor 现在是 1.2 版,所以您可能想要更改您正在引入的版本。