Some users of my swift 4.2 apps distributed on the macOS App store are reporting that the app crashes on startup if the target system has an out of date XCode installed.
Typical crashlogs look like this
Dyld Error Message:
Symbol not found: __TMSi
Referenced from: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftos.dylib
Expected in: /Applications/MYAPP.app/Contents/MacOS/../Frameworks/libswiftCore.dylib
in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftos.dylibWhy is the dynamic linker using libraries in the /Applications/XCode bundle when everything that the app needs is in the app bundle Frameworks folder ?
The above example was with an app built with XCode 10.2, run on a 10.13.6 machine, with XCode 9. Similar errors occur on a machine running 10.14.4 but with XCode 10.1 installed. The crash can be avoided by deleting or renaming XCode.
All the swift libraries are in the application Frameworks folder and using otool -L on the executable shows that all the swift libraries (bar one) are in the linked library list and are simply prefixed by @rpath. None of the linked libraries refer to XCode.
I do note however that while the library libswiftos.dylib is present in the app bundle Frameworks, it is not listed by otool -L.
How can I prevent the app using potentially incompatible swift libraries in any old XCode, and force it to just use the libraries it is bundled with instead ?
Thanks for any pointers.
I found one other similar report here, but there was no soluton mentioned