Swift Package Manager无法解析

时间:2017-11-22 09:54:30

标签: swift-package-manager

我目前正在尝试在完美服务器端Swift项目上使用Swift Package Manager,但是当我运行Swift package update时,它永远无法解析。使用详细标记,它似乎一遍又一遍地循环遍历相同的依赖项。

我认为问题的开始是我尝试创建自定义程序包以导入到我的项目中。我尝试以一种可以将其导入其他项目的方式构建软件包。问题是我的包本身依赖于一个完美的依赖关系。如果我从整个项目包中删除我的自定义包,依赖项下载成功。所以我只能假设我的包装有问题。

我的包的依赖关系看起来像这样

let package = Package(
    name: "TestPackage",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "TestPackage",
            targets: ["TestPackage"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
    .Package(url: "https://github.com/PerfectlySoft/Perfect-HTTP.git", majorVersion: 3),
    ],
    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: "TestPackage",
            dependencies: ["PerfectHTTP"]),
        .testTarget(
            name: "TestPackageTests",
            dependencies: ["TestPackage"]),
    ]
)

然后我的主项目的package.swift文件看起来像这样

let package = Package(
    name: "json_api",
    targets: [],
    dependencies: [
        .Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 3),
        .Package(url:"/local/path/to/TestPackage", majorVersion:0, minor:1),
    ]
)

正如您所看到的,他们都导入了Perfect-HTTP包(Perfect-HTTP-Server通过

执行此操作)

.package(url: "https://github.com/PerfectlySoft/Perfect-HTTP.git", from: "3.0.0"),

当它挂起时,它会继续获得Perfect-COpenSSLPerfect-Thread而不是Perfect-HTTP

我对SPM很陌生,这是我第一次尝试创建自己的软件包。我该如何尝试解决我只能假设的某种循环依赖问题?

1 个答案:

答案 0 :(得分:3)

所以我设法解决了这个问题并认为它可能对其他人有用。

我在git中将我的版本标签设为'v0.1',而我需要给它完整的语义版本,例如0.1.0作为标签并且成功运行