I have problems running a project in Xcode 5.0.2
I get the following error:
dyld: Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest
Ref
For our case, we want to use Mockingjay
for both app target and test target
target 'MyProject' do
pod 'Mockingjay/Core'
# all pods that are not test go here
target 'MyProjectTest' do
inherit! :search_paths
pod 'Mockingjay/XCTest'
pod 'Quick', ' ~> 0.9.2'
# .. all test pods go here
end
end
I had this error using ios-snapshot-test-case v5.0.2 via Carthage. The problem is related to XCode 11. Apple renamed libswiftXCTest.dylib
to libXCTestSwiftSupport.dylib
and added XCTest.swiftmodule
which has the same symbols in it and can work in place of the old one. But Apple forgot to tell iOS 11.x simulators about this change.
So you need to fix the older iOS version simulators. Here is the terminal command that fixed it for me:
sudo zsh -c ' sourcedir="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib";
targetdir="/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib";
ln -s $sourcedir/libXCTestSwiftSupport.dylib $targetdir/libswiftXCTest.dylib;
ln -s $sourcedir/XCTest.swiftmodule $targetdir/XCTest.swiftmodule'
See my comment here: https://github.com/CocoaPods/CocoaPods/issues/9165#issuecomment-573523322
I ran into this error by renaming my targets one of which was a testing target. After reading the other answers I realized that my Build Phases > Compile Sources was including test classes as compile sources for non-test targets which then tried to import the XCTest framework.
Removing the test classes from my regular target’s Compile Sources solved this for my case.
In my case It was RxTests added by Swift Package Manager to main application target. In pods you decide which Rx components add to which target, but SPM adds it all to main target as default.
enter the reference of your framework on framework search path AND Run path search path under "Build Settings"---...Now all set to invoke your projects by using import
It looks like your main target is linking to XCTest.framework as well as your test target. It should only be linked to the main target.
1) Go to Project settings
2) Go to your apps main target -> other linker flags
3) remove '-framework XCTest'
4) make sure the 'other linker flags' field for your test target still contains '-framework XCTest'