SwiftPM cannot resolve package dependencies and crashes Xcode

Hello!

When I add a specific dependency to my Package.swift (https://github.com/hectr/swift-http-client.git) file, SPM stops working (It cannot resolve package dependencies):

$ swift package resolve
Fatal error: 'try!' expression unexpectedly raised an error: TSCBasic.GraphError.unexpectedCycle: file /Library/Caches/com.apple.xbs/Sources/swiftpm/swiftpm-16074/Sources/Workspace/Workspace.swift, line 1112
zsh: illegal hardware instruction  swift package resolve

I attempted to use the dependency using a tag, the branch name and a local folder in my machine, but the outcome was the same. Renaming the library didn't help either.

The minimal Package.swift file that reproduces the crash is this:

// swift-tools-version:5.1

import PackageDescription

let package = Package(
    name: "Package",
    platforms: [
        .iOS(.v10),
    ],
    products: [],
    dependencies: [
       .package(url: "https://github.com/hectr/swift-http-client.git", .branch("master")),
    ],
    targets: [],
    swiftLanguageVersions: [.v5]
)

I have already reported this issue as a bug: https://bugs.swift.org/browse/SR-12482

Does anyone know what can I do differently to avoid this problem?

Thank you,
Hèctor

Just guessing here, but two of the packages in the dependency graph are named "Package". I don’t think package names are allowed to clash like that. Since one of them depends on the other, SwiftPM might think the package depends on itself. (The error is TSCBasic.GraphError.unexpectedCycle.)

I think we should file a bug for this but I think @SDGGiesbrecht is right on the money :slight_smile:.

Changing the package name solved the issue. SwiftPM was able to resolve dependencies and Xcode stopped crashing.

Thank you @SDGGiesbrecht and @johannesweiss :pray:

1 Like
Terms of Service

Privacy Policy

Cookie Policy