0

We have CLI tool written in Swift for common usage (Android and iOS developers) on macOS. Android developers without Xcode installation get the following error:

dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: ~/git/myClITool/macosBin Reason: image not found
Abort trap: 6

We found that enabling Always Embed Swift Standard Libraries in Xcode would most likely help, but this CLI tool is exported with SPM, ignoring all Xcode settings.

How can I achieve this build behaviour using SPM only?

Zsolt Molnár
  • 305
  • 2
  • 8

1 Answers1

2

Found the following commandline argument: --static-swift-stdlib

Example usage: swift build --static-swift-stdlib -c release

This would have produced the output we were looking for. Unfortunately since Swift 5, this argument no longer works for any platforms.

When used, SPM throws the following warning:

warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4 beta 3. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more/

Related Swift bugticket: https://bugs.swift.org/browse/SR-648

Zsolt Molnár
  • 305
  • 2
  • 8