-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Runpath Search Paths #1002
Description
Hi all,
I recently ran into an issue and the solution turned out to be somewhat google resistant. This github issue will serve two purposes:
- Document the problem and solution in a place where google will index it
- Ask if the community wants to document things like this in a Documentation/Gotchas.md file (or perhaps a closed but googleable github issue is sufficient for the solution to become known)
The problem is that unit tests don't work (the tests "fail" but Xcode didn't actually run them at all) in an iOS framework which includes another iOS framework (pulled in via Carthage).
I'll illustrate this with a more concrete example.
I've created an iOS Cocoa Touch Framework named FrameworkA.
FrameworkA's implementation is trivial:
FrameworkA has a trivial unit test which passes:
We then create FrameworkB, which uses FrameworkA.
FrameworkB's Cartfile looks like this:
git "../FrameworkA" "master"
We configure FrameworkB's Framework Search Paths to include the appropriate carthage build folder:
FrameworkB builds successfully.
We add a trivial unit test to FrameworkB:
However, when we run the unit tests, Xcode claims they failed. Examining the Report Navigator, we see that no tests were actually run, and we see this in the Logs tab:
Test target FrameworkBTests encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
Looking at the console, we see more specific errors about the dynamic linker failing to load FrameworkA:
2015-12-17 17:24:46.373 xctest[6701:5666799] The bundle “FrameworkBTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2015-12-17 17:24:46.390 xctest[6701:5666799] (dlopen_preflight(/Users/jpepas/Library/Developer/Xcode/DerivedData/FrameworkB-dooxtpkyrktrlxfqloozouhmeqoz/Build/Products/Debug-iphonesimulator/FrameworkBTests.xctest/FrameworkBTests): Library not loaded: @rpath/FrameworkA.framework/FrameworkA
Referenced from: /Users/jpepas/Library/Developer/Xcode/DerivedData/FrameworkB-dooxtpkyrktrlxfqloozouhmeqoz/Build/Products/Debug-iphonesimulator/FrameworkBTests.xctest/FrameworkBTests
Reason: image not found)
Program ended with exit code: 82
The solution is to add the carthage build directory to the Runpath Search Paths build setting on the unit test target.
Now the unit tests run.









