SwiftPM command plugin for assembling macOS/iOS .app bundles from Swift packages using a JSON configuration file.
- Create a config at
.spm-bundler.json(or pass--config path/to/config.json). Seespm-bundler.json.examplefor a starting point. - Run the plugin:
swift package --allow-writing-to-package-directory bundle [--configuration release] [--output Bundles] [--verbose] [--skip-sign]- The plugin builds the listed products (unless
binaryPathis provided), copies resources/frameworks/dylibs, writes anInfo.plist(or uses yours), and optionally codesigns. - Output defaults to
Bundles/<Name>.appunder the package root.
- The plugin builds the listed products (unless
Top-level keys:
configuration(optional): build configuration to request fromswift build(defaultrelease).outputDirectory(optional): where bundles are emitted; defaults toBundles.bundles: array of bundle specs.
Bundle fields:
name: display name for the emitted.app.product: SwiftPM product to build/copy into the bundle (ignored whenbinaryPathis used).platform:macosorios.bundleIdentifier: reverse-DNS identifier.version: version used for bothCFBundleVersionandCFBundleShortVersionString.minimumSystemVersion(optional): setsLSMinimumSystemVersion(macOS) orMinimumOSVersion(iOS).displayName(optional): overrides the name shown in the plist.infoPlist(optional): path to an existing plist to copy instead of the generated one.resources(optional): file/directory paths copied intoResources(macOS) or the app root/Resources (iOS).frameworks(optional): explicit file/directory paths copied intoFrameworks. If omitted, non-system frameworks are auto-discovered fromotool -L. Use[]to disable.dylibs(optional): explicit.dylibpaths copied intoFrameworks. If omitted, non-system dylibs are auto-discovered fromotool -L. Use[]to disable.binaryPath(optional): explicit path to a prebuilt binary (useful for iOS/xcconfigs). Otherwiseswift build --productis invoked.signing(optional):enabled(defaulttrue),identity,entitlements,options(array passed tocodesign --options, defaultruntime),deep(adds--deep).
- Codesigning is skipped if
signing.enabledis false,identityis empty, or--skip-signis supplied. - Frameworks/dylibs/resources are copied into the bundle and re-written to load from
@rpathwhen bundled.
- Ad-hoc: set
signing.identityto"-"; no entitlements required for macOS ad-hoc signing. - Local/self-signed: create a certificate in your login keychain and reference its Common Name in
signing.identity. - Assembly only: pass
--skip-signor setsigning.enabledtofalseto leave signatures untouched.
- Copy
spm-bundler.json.exampleto.spm-bundler.json, update product names/paths/identities, then run:swift package --allow-writing-to-package-directory bundle --verbose