I'm currently encountering an issue with the nightly-jammy version of the Swift client while running an end-to-end integration test for Swift packages hosted on JFrog Artifactory. The same setup works perfectly fine with the latest stable Swift client, so I suspect this might be a regression or behavioral change introduced in the nightly jammy.
This only fails on nightly-jammy, but passes successfully on the latest released client. The manifest structure hasn't been changed for quite some time.
My Inference
It seems like the nightly build is interpreting the manifest file differently, potentially due to changes in manifest parsing.
Request
Could someone from the community or SwiftPM team help confirm if this is a known change with nightly jammy? Any pointers or release notes that might help us adapt to this change (if intended) would be appreciated.
Package.swift file for reference
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "swiftpkg",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "swiftpkg",
targets: ["swiftpkg"]
),
dependencies: [ .package(url: "https://github.com/jfrog-qa/SwiftDepTest", from: "1.0.0"), ],
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "swiftpkg"
),
.testTarget(
name: "swiftpkgTests",
dependencies: ["swiftpkg"]
),
]
)
Would you be able to file a bug report with detailed reproduction steps and exact version of your toolchain and environment on SwiftPM's GitHub issues page?
Thanks for the pointers earlier. Based on the suggestion from @plemarquand in the GitHub thread, we're now considering replacing our current approach — which uses sed to inject .package lines into Package.swift — with the more resilient swift package add-dependency command.
This change seems necessary since the line numbers in the manifest generated via swift package init have recently shifted (as part of nightly builds), causing our existing E2E tests to fail.
That said, we often add dependencies with version ranges like:
I would suggest also filing this on the GitHub issues page on the SwiftPM repository. Even if it were already implemented (I'm not sure that's the case off the top of my head), not providing documentation or references in command help output would be a bug, your help in filing that is appreciated.
I just meant that the content of Package.swift must be a valid Swift code.
Apparently, the array literal in your Package.swift is syntactically invalid.
[
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "swiftpkg",
targets: ["swiftpkg"]
),
dependencies: [ .package(url: "https://github.com/jfrog-qa/SwiftDepTest", from: "1.0.0"), ],
]
Executing
swift package add-dependency https://example.com/swiftDep.git --from 1.0.0 --to 2.0.0
By the way, in Swift 6.1, swift package add-dependency --help will view the following message:
OVERVIEW: Add a package dependency to the manifest
USAGE: swift package add-dependency <dependency> [--exact <exact>] [--revision <revision>] [--branch <branch>] [--from <from>] [--up-to-next-minor-from <up-to-next-minor-from>] [--to <to>] [--type <type>]
ARGUMENTS:
<dependency> The URL or directory of the package to add
OPTIONS:
--exact <exact> The exact package version to depend on
--revision <revision> The specific package revision to depend on
--branch <branch> The branch of the package to depend on
--from <from> The package version to depend on (up to the next major version)
--up-to-next-minor-from <up-to-next-minor-from>
The package version to depend on (up to the next minor version)
--to <to> Specify upper bound on the package version range (exclusive)
--type <type> Specify dependency type (values: url, path, registry; default: url)
--version Show the version.
-h, -help, --help Show help information.
Hey @YOCKOW ,
Yes, you are right, I was using sedline command to add dependency at a particular line, and since the content of Package.swift changed, this lead to invalid manifest.
Also, thank you for pointing out the --from and --to flags, will use them.