Missing libXCTestSwiftSupport.dylib

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.

1 Like

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:

If you dig around in the Xcode bundle, you'll find two import components:



These two needed to be loaded by the application to run. There are several ways to make this work:

  1. Run install_name_tool and add the two containing directories for the above files into @rpath.
  2. Create a couple of symbolic links in the Xcode part of @rpath to the two files

Both of these made the executable run fine.

I still don't understand several things:

  1. Why does SPM create a @rpath pointing into the Xcode bundle? Shouldn't SPM be separate?
  2. Why is XCTest a required dylib in a release version. Is there something in my git library that requires it?

I am guessing the library you are linking requires XCTest somehow, but it's hard to say without seeing an example.

1 Like

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?

Ok, I figured it out. In the build settings, search for "Runpath Search Paths" and add the two folders mentioned in my previous comment:

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.


I forgot to add that you must also set "Enable Testing Search Paths" in the target(s) build settings to "Yes"

This saved me, man. Thanks for sharing this

Some how this was still happening and I figured out that one library was importing XCTest in a release version :exploding_head:

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.

Terms of Service

Privacy Policy

Cookie Policy