Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add-target command doesn't work with binary targets #8277

Open
1 task done
grantjbutler opened this issue Feb 4, 2025 · 0 comments
Open
1 task done

add-target command doesn't work with binary targets #8277

grantjbutler opened this issue Feb 4, 2025 · 0 comments
Labels

Comments

@grantjbutler
Copy link

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

The add-target command doesn't seem to properly support either creating a target that points to a remote binary artifact or creating a target that points to a local binary artifact. The arguments in the command exist, but the command doesn't seem to property process them and create the correct target type. For example, the following two commands fail, but in different ways (see "Actual Behavior" for how these fail):

swift package add-target Capacitor \
  --url "https://github.com/ionic-team/capacitor-swift-pm/releases/download/7.0.1/Capacitor.xcframework.zip" \
  --checksum "7781e0a8d8072c26132fd1170e4fe08ae72a98ef664e28176c7e43f241c3479e"
swift package add-target LocalBinaryDependency --path Artifacts/LocalBinaryDependency.xcframework

This seems to be because the presence of these arguments doesn't change the type of the target to be created from .regular to .binary. Some of these values being present gets caught in TargetDescription's validation and fails the command line call. Binary targets aren't supported, in the sense of the --type argument does not accept a value named binary to explicitly change the type of the created target to .binary, which would then map to a .binaryTarget value in the manifest.

I have limited knowledge of the internals of SPM, but I would hazard a guess that this could be addressed by adding a new binary case to the TargetType enumeration, and then properly mapping that to a TargetDescription.TargetKind.binary.

Expected behavior

Providing the information for a binary target would properly create a .binaryTarget target in the SPM package's manifest.

Actual behavior

For remote binary targets, the command will fail with the following error:

error: target 'Capacitor' contains a value for disallowed property 'url'

For local binary targets, the command succeeds, but creates a normal target, but with its path set in the manifest to the path provided to the command. The command will also create the target's source folders in the Sources/ folder.

Steps to reproduce

Use one of the command invocations included in the description of this ticket to attempt to create a new binary target in a package.

Swift Package Manager version/commit hash

Swift Package Manager - Swift 6.0.3

Swift & OS version (output of swift --version ; uname -a)

$ swift --version
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx14.0
$ uname -a
Darwin 603e5f49c974 23.6.0 Darwin Kernel Version 23.6.0: Fri Nov 15 15:12:52 PST 2024; root:xnu-10063.141.1.702.7~1/RELEASE_ARM64_T6031 arm64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant