Packaging binaries with SPM
Initialize an executable package, set the product , add dependencies, and produce a release binary from .build/release ready to share.
Why SwiftPM executables?
SwiftPM can build executables you can ship.
- Init executable package
- Define products and targets
- Add dependencies (semantic versions)
- Build release and find the binary
Init & build basics
Use swift package init --type executable to scaffold. Then swift build and swift run to compile and execute.
// In your terminal (for reference):
// swift package init --type executable
// Files created: Package.swift, Sources/<Target>/main.swift, Tests/
// You can then run:
// swift build
// swift run
print("SPM exec template ready")All lessons in this course
- Swift scripts (swift shebang), command-line tools
- C/Obj-C interop at a glance (no iOS specifics)
- Packaging binaries with SPM