# Missing libXCTestSwiftSupport.dylib

**URL:** <https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [April 12, 2020, 6:04pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314 "2020-04-12T18:04:40Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrsum](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rrsum/32/27011_2.png) [@rrsum](https://forums.swift.org/u/rrsum)\
**Post date:** [April 12, 2020, 6:04pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/1 "2020-04-12T18:04:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Iain\_Smith](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/iain_smith/32/394_2.png) [@Iain\_Smith](https://forums.swift.org/u/Iain_Smith)\
**Post date:** [April 12, 2020, 9:30pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/2 "2020-04-12T21:30:43Z")

</div>

This is apparently an internal change between Xcode 10 & 11 that tripped up a lot of users with prebuilt binaries.

From this GitHub issue.

> <https://github.com/CocoaPods/CocoaPods/issues/9165#issuecomment-550273696>
>
> \<!--
> ℹ Please fill out this template when filing an issue.
> All lines beginning… with an ℹ symbol instruct you with
> what info we expect.  
> 
> Before you start, are you using the latest CocoaPods release?
> A lot changes with Xcode releases that are not backwards compatible.
> 
> Not an issue about the CocoaPods command line app? Please file an issue in the appropriate repo - https://github.com/CocoaPods
> Issues are for feature requests, and bugs; questions should go to Stack Overflow
> 
> Using CocoaPods \<= 0.39: https://blog.cocoapods.org/Sharding/
> 
> Using Xcode 10.1: Requires CocoaPods 1.6.0 or above.
> 
> Issue with Nanaimo not loading:
> Please run \`\[sudo\] gem uninstall nanaimo\` and remove all but the latest version.
> 
> Issues with \`pod search\`? Try deleting your cache \`rm -rf ~/Library/Caches/CocoaPods\`first.
> \--\>
> 
> \* \[X\] I've read and understood the \[\*CONTRIBUTING\* guidelines and have done my best effort to follow\](https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md).
> 
> \# Report
> 
> \## What did you do?
> 
> I built a simple app that has 2 unit tests and 2 ui tests in Xcode 11 GM Seed 2. Its minimum deployment target is 11.0. I indicated that I want to use Cocoa Touch Frameworks in both my App target and Unit Test target, by declaring \`use\_frameworks!\` under both targets in the Podfile.
> 
> \## What did you expect to happen?
> 
> I expect to be able to build, and run both unit and ui tests successfully for iOS 11, 12, and 13 simulators and devices.
> 
> \## What happened instead?
> 
> The project compiles but does not run unit or ui tests on any iOS 11 version simulator. This includes iOS versions 11.0, 11.1, 11.2, 11.3, 11.4. This is the error message:
> \`2019-09-18 11:45:49.838967-0400 xctest\[33269:1591375\] The bundle “TestAppTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
> 2019-09-18 11:45:49.839132-0400 xctest\[33269:1591375\] (dlopen\_preflight(/Users/dvataksi/Library/Developer/Xcode/DerivedData/TestApp-dudbjerumgardlbyxjegkcjhkdiq/Build/Products/Debug-iphonesimulator/TestAppTests.xctest/TestAppTests): Library not loaded: @rpath/libswiftCoreGraphics.dylib
> Referenced from: /Applications/Xcode\_11\_GM2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib
> Reason: no suitable image found. Did find:
> /usr/lib/swift/libswiftCoreGraphics.dylib: mach-o, but not built for iOS simulator
> /usr/lib/swift/libswiftCoreGraphics.dylib: mach-o, but not built for iOS simulator)
> Program ended with exit code: 82\`
> 
> 
> \## CocoaPods Environment
> 
> \### Stack
> 
> \`\`\`
> CocoaPods : 1.7.5
> Ruby : ruby 2.5.1p57 (2018-03-29 revision 63029) \[x86\_64-darwin18\]
> RubyGems : 3.0.6
> Host : Mac OS X 10.14.6 (18G87)
> Xcode : 10.3 (10G8)
> Git : git version 2.17.1
> Ruby lib dir : /Users/myusername/.rbenv/versions/2.5.1/lib
> Repositories : master - https://github.com/CocoaPods/Specs.git @ 68612e4c07451e618fd1beb8d6b708fa34385081
> \`\`\`
> 
> \### Installation Source
> 
> \`\`\`
> Executable Path: /Users/myusername/.rbenv/versions/2.5.1/bin/pod
> \`\`\`
> 
> \### Plugins
> 
> \`\`\`
> cocoapods-deintegrate : 1.0.4
> cocoapods-plugins : 1.0.0
> cocoapods-search : 1.0.0
> cocoapods-stats : 1.1.0
> cocoapods-trunk : 1.3.1
> cocoapods-try : 1.1.0
> \`\`\`
> 
> 
> 
> \## Project that demonstrates the issue
> 
> Download the demo project here -\> https://github.com/dvataksi16/TestApp

> 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.

---

<div class="post-metadata">

**Author:** ![rrsum](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rrsum/32/27011_2.png) [@rrsum](https://forums.swift.org/u/rrsum)\
**Post date:** [April 13, 2020, 11:50pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/3 "2020-04-13T23:50:31Z")

</div>

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:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework

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?

---

<div class="post-metadata">

**Author:** ![NeoNacho](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/neonacho/32/1368_2.png) [@NeoNacho](https://forums.swift.org/u/NeoNacho)\
**Post date:** [April 13, 2020, 11:55pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/4 "2020-04-13T23:55:50Z")

</div>

> [@rrsum](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Peter-Schorn](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/peter-schorn/32/11183_2.png) [@Peter-Schorn](https://forums.swift.org/u/Peter-Schorn)\
**Post date:** [June 9, 2020, 11:33am UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/5 "2020-06-09T11:33:06Z")

</div>

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:

```swift
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?

---

<div class="post-metadata">

**Author:** ![Peter-Schorn](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/peter-schorn/32/11183_2.png) [@Peter-Schorn](https://forums.swift.org/u/Peter-Schorn)\
**Post date:** [June 9, 2020, 1:00pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/6 "2020-06-09T13:00:28Z")

</div>

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

 ![Screen Shot 2020-06-09 at 8.00.04](https://global.discourse-cdn.com/swift/original/2X/1/1ce288c2bca260b21e23a4fb265902a32c17e151.png)

---

<div class="post-metadata">

**Author:** ![chivalrous](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@chivalrous](https://forums.swift.org/u/chivalrous)\
**Post date:** [June 21, 2020, 2:05pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/7 "2020-06-21T14:05:20Z")

</div>

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.

 ![Screenshot 2020-06-21 at 14.50.23](https://global.discourse-cdn.com/swift/original/2X/3/38c0208e97c9b3e74db3dc10240ff8f1b7555640.jpeg)

---

<div class="post-metadata">

**Author:** ![Peter-Schorn](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/peter-schorn/32/11183_2.png) [@Peter-Schorn](https://forums.swift.org/u/Peter-Schorn)\
**Post date:** [July 26, 2020, 5:40am UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/8 "2020-07-26T05:40:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobitech](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tobitech/32/10547_2.png) [@tobitech](https://forums.swift.org/u/tobitech)\
**Post date:** [January 3, 2021, 2:40am UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/9 "2021-01-03T02:40:49Z")

</div>

This saved me, man. Thanks for sharing this

---

<div class="post-metadata">

**Author:** ![bobgodwinx](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bobgodwinx/32/4481_2.png) [@bobgodwinx](https://forums.swift.org/u/bobgodwinx)\
**Post date:** [February 22, 2021, 11:16pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/10 "2021-02-22T23:16:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cyberbeni](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/cyberbeni/32/46241_2.png) [@Cyberbeni](https://forums.swift.org/u/Cyberbeni)\
**Post date:** [February 23, 2021, 5:16pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/11 "2021-02-23T17:16:04Z")

</div>

> [@Peter-Schorn](#):
>
> "Enable Testing Search Paths"

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.

---

<div class="post-metadata">

**Author:** ![bkryslky](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bkryslky/32/16348_2.png) [@bkryslky](https://forums.swift.org/u/bkryslky)\
**Post date:** [April 5, 2021, 8:11pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/12 "2021-04-05T20:11:46Z")

</div>

If you are not using RxBlocking and RxTest, you can remove these from Link Binary With Libraries under Build Phases tab. Then it works

---

<div class="post-metadata">

**Author:** ![irsyadashari](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/irsyadashari/32/18892_2.png) [@irsyadashari](https://forums.swift.org/u/irsyadashari)\
**Post date:** [July 26, 2021, 2:51pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/13 "2021-07-26T14:51:09Z")

</div>

this one des it for me, thank u

---

<div class="post-metadata">

**Author:** ![goldena](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/goldena/32/20721_2.png) [@goldena](https://forums.swift.org/u/goldena)\
**Post date:** [December 13, 2021, 11:27am UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/14 "2021-12-13T11:27:06Z")

</div>

Thanks!

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.

---

<div class="post-metadata">

**Author:** ![BalintZoo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/balintzoo/32/34546_2.png) [@BalintZoo](https://forums.swift.org/u/BalintZoo)\
**Post date:** [March 18, 2024, 2:13pm UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/15 "2024-03-18T14:13:21Z")

</div>

Thank you for posting this. You saved me from a couple of days of headaches!

---

<div class="post-metadata">

**Author:** ![ronee12](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ronee12/32/35042_2.png) [@ronee12](https://forums.swift.org/u/ronee12)\
**Post date:** [April 23, 2024, 9:30am UTC](https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/16 "2024-04-23T09:30:36Z")

</div>

Thanks, It working now.
