Swift Package Scripts has Terminal scripts that can be used to build and test your package, build DocC and deploy it to GitHub Pages, generate XCFramework binary artifacts, create new semantic versions, etc.
Swift Package Scripts also has a collection of GitHub Actions workflows that can run some scripts from the GitHub Actions dashboard.
Swift Package Scripts can be installed to your computer by cloning the repository:
git clone https://github.com/danielsaidi/SwiftPackageScripts.git
You can then navigate to the folder and sync the scripts to any older folder, using the /sync-to.sh script.
./sync-to.sh ../AnotherPackage [--github-workflows 1]This will replace any existing scripts with the latest versions. After this, you can use scripts/sync-from.sh in that project folder.
The scripts folder contains Swift Package-related scripts, that can all be customized with their own parameters:
build.sh- Build a target for all or some platforms.chmod-all.sh- Runschmod +xon all scripts in the script folder.docc.sh- Build DocC documentation for all or some platforms.git-default-branch.sh- Get the default git branch name.l10n-gen.sh- Generate public translation key wrappers from an Xcode 26 string catalog.package-name.sh- Get the name of the main Swift package.release.sh- Make a release build with several validation steps.release-validate-git.sh- Validate the git repo for release.release-validate-package.sh- Validate the package for release.sync-from.sh- Syncscriptsand.github/workflowsfrom a Swift Package Scripts folder.sync-to.sh- Syncscriptsand.github/workflowsto another package folder.test.sh- Test a target on all or some platforms.version-bump.sh- Bump the current version number and create a new tag.version-number.sh- Get the current version number from the latest tag.xcframework.sh- Build an XCFramework for all or some platforms.
All scripts have a --help command, e.g. ./scripts/build.sh --help. Note that you have to run chmod +x <SCRIPT> to be able to run a script for the first time.
The .github folder contains the following GitHub Actions workflows:
build.yml- Build the package for all or some platforms.docc.yml- Build DocC documentation and deploy it to GitHub Pages.test.yml- Test the package on all or some platforms.version_bump.yml- Bump the current version number and create a new tag.xcframework.yml- Build an XCFramework and dSYMs for all or some platforms.
Have a look at each file for workflow-specific information and if there is anything you need to do to make it work.
SwiftPackageScripts has an l10n-gen.sh script that can generate public, namespaced key wrappers from any Xcode string catalog.
Once generated, these public keys can be used from any package and app, wherever a LocalizedStringResource is expected:
Text(.l10n.myapp.onboardings.welcome.title)You can read more about this in the localization article.
This repository has a sample package that is used to test that everything works as expected.
For more information about these scripts, and how to set up project-specific scripts, see the online here.
You can become a sponsor to help me dedicate more time on my various open-source tools. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
Feel free to reach out if you have questions or if you want to contribute in any way:
- Website: danielsaidi.com
- Mastodon: @danielsaidi@mastodon.social
- Twitter: @danielsaidi
- E-mail: daniel.saidi@gmail.com
Swift Package Scripts is available under the MIT license. See the LICENSE file for more info.