Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 5 throws "Library not loaded" error when adding a test target

I've tried adding a test target on Xcode 5 using the Add Target -> Add Cocoa Touch Unit Testing Bundle. However, when I run the test, I get the following error:

2013-09-24 10:43:14.446 Stack Exchange[48895:c07] Error loading /Users/arielitovsky/Library/Developer/Xcode/DerivedData/MyApp-fjegcztcnwxqdfdimhonqzzqpdwr/Build/Products/Debug-iphonesimulator/Stack Exchange Tests.xctest/Stack Exchange Tests: dlopen(/Users/arielitovsky/Library/Developer/Xcode/DerivedData/MyApp-fjegcztcnwxqdfdimhonqzzqpdwr/Build/Products/Debug-iphonesimulator/Stack Exchange Tests.xctest/Stack Exchange Tests, 262): Library not loaded: /Developer/Library/Frameworks/XCTest.framework/XCTest Referenced from: /Users/arielitovsky/Library/Developer/Xcode/DerivedData/MyApp-fjegcztcnwxqdfdimhonqzzqpdwr/Build/Products/Debug-iphonesimulator/Stack Exchange Tests.xctest/Stack Exchange Tests Reason: image not found IDEBundleInjection.c: Error loading bundle '/Users/arielitovsky/Library/Developer/Xcode/DerivedData/MyApp-fjegcztcnwxqdfdimhonqzzqpdwr/Build/Products/Debug-iphonesimulator/Stack Exchange Tests.xctest' Program ended with exit code: 0

Why isn't this working?

like image 784
Arie Litovsky Avatar asked Sep 24 '13 15:09

Arie Litovsky


2 Answers

You must run your test on the iOS 7 simulator. It will not work on iOS 6.x.

like image 95
Arie Litovsky Avatar answered Nov 19 '22 10:11

Arie Litovsky


I have fixed this by setting the General Tab -> Deployment Target to 7.0 (for the app that you are using to "run" the unit tests). This is not great if you want to support earlier than 7.0 for your main App. But since there is no Deployment Target on the unit test build target you cannot set it there. You instead have to set the Target of the unit tests (on General tab) to the App whose Deployment Target is 7.0. You can setup a "TestApp" to do this so you don't have to restrict your main app's deployment.

like image 27
Temporaneous Avatar answered Nov 19 '22 12:11

Temporaneous