SPM Portability / static linking

With the latest release of Xcode, all of my SPM built tools are failing to run again. This is kind of confusing for me since I used release mode when I built them. Is there anyway to build an SPM project so that it can be run on another computer without the Swift tools installed or with different swift tools installed?

You can link the stdlib statically with SwiftPM like this:

swift build --configuration release -Xswiftc -static-stdlib

SwiftPM has an option to make this easier --static-swift-stdlib. With Swift 4.0 it seemed to be a no-op on macOS, I haven’t tested it with 4.1 to see if it’s fixed.

4 Likes