In trying to get the example project tests running on a fresh machine, I ran into build problems. I actually ran into this same type of problem when installing applesimutils (https://github.com/wix/AppleSimulatorUtils/pull/9), so I'll quote myself:
xcodebuild takes a -derivedDataPath option that seems like it should place all build artifacts in that folder. But it seems like it only puts some artifacts in there, and it is still putting the binary in a different location (by default, in ~/Library/Developer/Xcode/DerivedData).
When running the example tests in release (or debug) mode per the instructions, I first get:
detox-server info 13:37:43: server listening on localhost:49933...
detox info 1: Searching for device matching iPhone 6...
detox info Building Detox.framework (5.8.1) into /Users/gerard/Library/Detox/ios/69ec938fe7df49aef2463408303498305f87bb24...
1) "before all" hook
0 passing (1m)
1 failing
1) "before all" hook:
Error: Command failed: /Users/gerard/_work/detox/examples/demo-react-native/node_modules/detox/scripts/build_framework.ios.sh "/Users/gerard/_work/detox/examples/demo-react-native/node_modules/detox" "/Users/gerard/Library/Detox/ios/69ec938fe7df49aef2463408303498305f87bb24"
mv: rename /Users/gerard/Library/Detox/ios/69ec938fe7df49aef2463408303498305f87bb24/DetoxBuild/Build/Products/Release-universal/Detox.framework to /Users/gerard/Library/Detox/ios/69ec938fe7df49aef2463408303498305f87bb24/Detox.framework: No such file or directory
`/Users/gerard/_work/detox/examples/demo-react-native/node_modules/detox/scripts/build_framework.ios.sh "/Users/gerard/_work/detox/examples/demo-react-native/node_modules/detox" "/Users/gerard/Library/Detox/ios/69ec938fe7df49aef2463408303498305f87bb24"` (exited with error code 1)
This is because Detox.framework got put in ~/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/Detox.framework instead of where the script expects it: ~/Library/Detox/ios/.../DetoxBuild/Build/Products/Release-universal/Detox.framework.
If I append BUILD_DIR="${detoxFrameworkDirPath}"/DetoxBuild/Build/Products to the end of the xcodebuild command in scripts/build_framework.ios.sh, it puts it in the expected location.
Then, when I re-run detox test, I get the same type of error because detox build did not get put where expected:
detox-server info 14:07:06: server listening on localhost:58302...
1) "before all" hook
0 passing (90ms)
1 failing
1) "before all" hook:
Error: app binary not found at '/Users/gerard/_work/detox/examples/demo-react-native/ios/build/Build/Products/Release-iphonesimulator/example.app', did you build it?
at Device._getAbsolutePath (node_modules/detox/lib/devices/Device.js:202:15)
Same problem with xcodebuild in package.json.
I'm not sure why this works out-of-the-box for some but not others. There is nothing unique about my Xcode installation AFAIK. I have updated it from the App Store for years. Also, I'm not an Xcode developer, so I don't know the difference between -derivedDataPath and BUILD_DIR. The Apple docs aren't helpful.
Just following the instructions for release mode in examples/demo-react-native/README.
Thanks for opening this issue.
This bugs me, and I want to investigate this further. One workaround is we append that BUILD_DIR but I want to understand why it helps.
Could be related to location settings in Xcode preferences. Could you please paste a screenshot of those? Xcode (menu) -> Preferences -> Locations
@LeoNatan

馃挬
Thanks! I will investigate.
I had this issue a few months back with Xcode 8.3.3 after messing with the defaults. I took me a while to solve this.
Eventually I changed everything back to default, deleted and reinstalled Xcode. it now respects derivedDataPath again.
@LeoNatan @rotemmiz can you screenshot your location settings in Xcode if it is not default? I can try with that setup.
My settings are default in both the main screen and in Advanced.
Did you reinstall Xcode?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions.
@LeoNatan I just had this problem, in the end, this was fixed?