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:
- Add EarlGrey.framework.
- Select destination as
Absolute Path
- Set path to
$(TEST_HOST)/..
- Uncheck "Copy files only when installing"
- Check(✓) "Code Sign on Copy"
Note that these instructions are present under "Final Test Configuration" in the link mentioned above.