0

I'm following the instructions in the Github Installation section for integrating EarlGrey in my app. I've set up the test target and added EarlGrey by dragging it into my project, along with adding it as a framework dependency. However, on running my test, I get the following error:

dyld: Library not loaded Reason: image not found

Is there anything specific that I need to do in my project that is required to solve this issue?

gran_profaci
  • 8,087
  • 15
  • 66
  • 99

1 Answers1

2

The error you mentioned:

dyld: Library not loaded Reason: image not found

indicates that the dynamic loader is not able to find the EarlGrey dynamic framework to load. There can be a variety of reasons for this can happen:

As noted in Add EarlGrey as dependency

You must add the following to your scheme:

Key: `DYLD_INSERT_LIBRARIES`
Value:`@executable_path/EarlGrey.framework/EarlGrey`

Note that Value must be @executable_path so that the dynamic loader can find that library when run on device, if the path refers to a location on the dev machine (thats running Xcode) tests will work on simulator but not on device and the same error will occur. Above step sets the path, next important thing to do is to tell Xcode to copy EarlGrey dynamic library into that path. Use the Build Phase's "Copy files" to do that:

  1. Add EarlGrey.framework.
  2. Select destination as Absolute Path
  3. Set path to $(TEST_HOST)/..
  4. Uncheck "Copy files only when installing"
  5. Check(✓) "Code Sign on Copy"

Note that these instructions are present under "Final Test Configuration" in the link mentioned above.

Gautam
  • 286
  • 1
  • 3