I've been using Swift for several years now and it has replaced perl for me, at least on a mac. Over the past few years, I've build up a set of libraries for dealing with databases and have stored them away on my own git server. I've built several executables that talk to the databases and everything has been working fine.
I recently downloaded the latest version of Xcode (11.4) and now none of the executables run after rebuilding. The can't find libXCTestSwiftSupport.dylib, even when compiling from the command line package manager or from within Xcode, and even for the release version (why would a release version need XCTest?).
As a test, I created a new Swift executable, compiled the startup "Hello World" code, and it ran fine. I then added a dependency consisting of one of my working libraries. Running the executable then failed with the above error.
Am I missing something here, or is this a known problem? Is there a work around? Thanks in advance.
This is apparently an internal change between Xcode 10 & 11 that tripped up a lot of users with prebuilt binaries.
From this GitHub issue.
Since Xcode 11, you should be linking against libXCTestSwiftSupport.dylib instead of the old libswiftXCTest.dylib which is obsolete. The set of symbols exported by the new library should be nearly identical.
Thanks to lain for his response. After poking around a bit, I was able to come up with a couple of work arounds. I created a test package called "test" and added the dependency library. Note that this was all done independent of Xcode, and everything below was done from the command line. Moreover, the library in question was imported via swift/git, so it wasn't in any binary form already.
I used swift build to make the package and then ran otools -L on the binary. This yielded the following:
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1675.129.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1675.129.0)
@rpath/libXCTestSwiftSupport.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1103.8.25)
@rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 0.0.0)
Moreover, @rpath consisted of the usual plus: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx
If you dig around in the Xcode bundle, you'll find two import components:
I ran into this issue when I added an extension to XCTestCase in a library that I created. More specifically, I got the following runtime error:
dyld: Library not loaded: @rpath/libXCTestSwiftSupport.dylib
I'm not familiar with install_name_tool. Presumably I need to add /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/ and /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/ to my @rpath (what is this?). Can someone show me how to do this?
I would like to share my experience with this error. It happened to me when I installed RxSwift via SPM.
So this was the problem: I assigned RxTest and RxBlocking to App Target instead of Test Target changing that solved the issue.
When did they add this option? I'm pretty sure for UI testing on older macOS versions(macOS 10.11, Xcode 8.2), you still need the other linker flags and manually specified search paths.
I haven't found this screen in Xcode 13.1 (might have been removed) and ended up removing RxBlocking and RxTest from Target > Built Phases > Link Binary With Libraries, and adding them to in the Tests Target (to the same place).
RxSwift was installed via SPM as well.