The resolution of packages seems to be broken in swift package manager, when using the resolution of package with flag "--use-registry-identity-for-scm" that replaces scm dependencies with packages hosted on the swift package registry.
For example this command:
swift package resolve --use-registry-identity-for-scm
the swift package manager does not seem to work in such cases.
Below is code snippet from the swift-crypto Package.swift file, that seems to be the culprit:
dependencies: [
.package(url: "https://github.com/apple/swift-asn1.git", from: "1.2.0")
],
.target(
name: "_CryptoExtras",
dependencies: [
"CCryptoBoringSSL",
"CCryptoBoringSSLShims",
"CryptoBoringWrapper",
"Crypto",
.product(name: "SwiftASN1", package: "swift-asn1")
],
exclude: privacyManifestExclude + [
"CMakeLists.txt",
],
resources: privacyManifestResource,
swiftSettings: swiftSettings
),
I think what is happening is that the registry replaces the https://github.com/apple/swift-asn1.git
with the package from the registry, that uses package id name.scope in this case apple.swift-asn1 . Then the line .product(name: "SwiftASN1", package: "swift-asn1")
fails to resolve, because it cannot find the dependency.
The concrete error is:
error: 'apple.swift-crypto': product 'SwiftASN1' required by package 'apple.swift-crypto' target '_CryptoExtras' not found in package 'swift-asn1'. Did you mean '.product(name: "SwiftASN1", package: "apple.swift-asn1")'?
The resolution seems to use the end of the url as package id instead of the scope.local syntax, if I try to correct it from product(name: "SwiftASN1", package: "swift-asn1")
to .product(name: "SwiftASN1", package: "apple.swift-asn1")
, it it says error: 'swift-crypto': unknown package 'apple.swift-asn1' in dependencies of target '_CryptoExtras'; valid packages are: 'swift-asn1' (from 'https://github.com/apple/swift-asn1.git')
This seems to me as bug in the swift package manager.
At the moment it is blocker for our swift package registry in CI&CD pipelines, because the resolution of dependencies does not work in such cases
For more details how to reproduce: