Add binary target to package definition #210
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Nowadays Xcode can't use executable targets for Build Tool plugins. As a workaround, plugins may use binary targets.
The definition of a binary target is straightforward. But automatic uploads require some additional setup.
Also, Xcode needs an artifact with a valid checksum to resolve the package dependencies. Thus the first artifact should be uploaded to GitHub manually.
Solution
Target definition
LicensePlistBinary
– the name of the target, the future plugins will use this name.url
– direct URL to download bundle artifact.checksum
– SHA-256 hash of the artifact.Bundle content
The bundle artifact should be a zip archive. It includes:
info.json
with metadata,The metadata includes the artifact name, path, and supported platforms.
Automatization
What should the release script do to upload bundle artifacts to GitHub?
info.json
including the updated version.Package.swift
accordingly to a new release.Package.swift
with updated information.Chicken or the egg problem
The pushed code can't be even built by Xcode because of the binary target with the missed artifact.
This could be solved by @mono0926. Unfortunately, the fix requires some manual work.
To upload the first bundle artifact the maintainer need:
binaryTarget(...)
definition inPackage.swift
.make spm_artifactbundle_macos
to create an archive.shasum -a 256 LicensePlistBinary-macos.artifactbundle.zip
.Upcoming releases might upload bundle artifacts automatically.
Fixes
Package.swift
definition,spm_artifactbundle_macos
task to Makefile,TEMPORARY_FOLDER
folder path changed to a more general one,build
andbuild_portable
depend onclean
,clean
removes the temporary folder,get-version
script to determine the package version insidemake
command,update-artifact-bundle.sh
to automatically update URL and checksum,release.sh
added commands to make and upload bundle artifacts, and to push updatedPackage.swift
file.