Skip to content

Runpath Search Paths #1002

@cellularmitosis

Description

@cellularmitosis

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.

screen shot 2015-12-17 at 5 18 21 pm

FrameworkA's implementation is trivial:

screen shot 2015-12-17 at 5 20 46 pm

FrameworkA has a trivial unit test which passes:

screen shot 2015-12-17 at 5 21 17 pm

We then create FrameworkB, which uses FrameworkA.

screen shot 2015-12-17 at 5 23 59 pm

FrameworkB's Cartfile looks like this:

git "../FrameworkA" "master"

We configure FrameworkB's Framework Search Paths to include the appropriate carthage build folder:

screen shot 2015-12-17 at 5 27 39 pm

FrameworkB builds successfully.

We add a trivial unit test to FrameworkB:

screen shot 2015-12-17 at 5 50 15 pm

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)

screen shot 2015-12-17 at 5 29 22 pm

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

screen shot 2015-12-17 at 5 31 37 pm

The solution is to add the carthage build directory to the Runpath Search Paths build setting on the unit test target.

screen shot 2015-12-17 at 5 42 50 pm

Now the unit tests run.

screen shot 2015-12-17 at 5 46 38 pm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions