I have a Swift command line tool embedded in a Swift application that is compiled to run on macOS 10.10 and later.
After upgrading the application and tool to Swift 5, will users on macos 10.14.3 and earlier have to install the Swift 5 Runtime Support?
Is there anyway to link or invoke the tool so that it uses the Runtime Libraries already embedded in the Frameworks directory of the application bundle?
Earlier I wrote:
You’ve hit an interesting edge case.
I talked to folks internally and there’s a general consensus that resolving this edge case — as a reminder, we’re specifically referring to the problem where you’re shipping a GUI app with an embedded helper tool — by having the helper tool reference the host app’s Swift runtime is fine.
The one thing to watch out for is the rpath setup in your tool. You have to make sure that the tool’s rpath references
/usr/lib/swift
first and the embedded runtime second. That way, the tool will use the system runtime if it’s available, and then fallback to the embedded runtime.
For example, if you take Xcode 10.2, create a new Swift app, and then build it, the app’s rpath setup looks like this:
$ otool -l ***.app/Contents/MacOS/***
…
Load command 30
cmd LC_RPATH
cmdsize 32
path /usr/lib/swift (offset 12)
Load command 31
cmd LC_RPATH
cmdsize 48
path @executable_path/../Frameworks (offset 12)
…
Your tool will need to ape this, using an appropriate relative path in the second entry.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"