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.
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.
The pushed URL and checksum are specified as an example. The artifact doesn't exist and it isn't uploaded.
Bundle content
The bundle artifact should be a zip archive. It includes:
info.json with metadata,
license,
fat binary for x86 and arm64.
The metadata includes the artifact name, path, and supported platforms.
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.