Skip to content

Instantly share code, notes, and snippets.

@liamnichols
Last active April 14, 2020 13:35
Show Gist options
  • Save liamnichols/3507faf70ecca201cb4300645caa9b74 to your computer and use it in GitHub Desktop.
Save liamnichols/3507faf70ecca201cb4300645caa9b74 to your computer and use it in GitHub Desktop.
Fix for missing libswiftXCTest.dylib when trying to run Unit Tests in Xcode 11.1 on an iOS 11 simulator
sudo mkdir /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift
sudo ln -s /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/Swift/libswiftXCTest.dylib /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift
@muehlemann
Copy link

This is awesome! I was stuck on this issue for weeks and creating the symbolic link fixed it for me. Thank you!

@schroepf
Copy link

schroepf commented Nov 12, 2019

OMG! Thanks!

@liamnichols
Copy link
Author

@muehlemann: Glad it helped! I haven't tried it, but I also spotted this comment which might be the real "fix":

CocoaPods/CocoaPods#9165 (comment)

@muehlemann
Copy link

@liamnichols Great thanks for the info, will be watching that cocoapods issue.

@1oo7
Copy link

1oo7 commented Jan 13, 2020

@muehlemann: Glad it helped! I haven't tried it, but I also spotted this comment which might be the real "fix":

CocoaPods/CocoaPods#9165 (comment)

This cocoapods "fix" doesn't really help because it means you have to modify the framework's .xcodeproj and then rebuild the framework. If that framework is a third-party dependency that you're including via CocoaPods or Carthage, then actually the kind of solution you're suggesting is a much better idea.

But one thing sticks out from Apple's suggested fix mentioned on that thread: they are saying that libswiftXCTest.dylib is obsolete and has been replaced by libXCTestSwiftSupport.dylib, which "should" have all the same symbols in it. So, if you want to use this newer .dylib, then you would want to set up your symlinks like this:

sudo mkdir /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift
sudo ln -s /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/Swift/libswiftXCTest.dylib /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift 

Personally I think this is due to a bug in XCode... it should be able to find that .dylib. But Apple has created a literal hell of duplicated directory trees throughout their development apps like XCode and Simulator. It's gotten so out of control that it's no wonder this kind of problem is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment