Detox: postinstall script fails

Created on 15 Aug 2018  ·  28Comments  ·  Source: wix/Detox

Description

Trying to run npm install detox --save-dev will fail with the following error in the detox_ios.log
~
CodeSign build/Build/Products/Release-iphonesimulator/Detox.framework
/usr/bin/codesign --force --sign - --timestamp=none /_PROJECT_PATH_/node_modules/detox/ios_src/build/Build/Products/Release-iphonesimulator/Detox.framework
cp: /Users/Dan/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/DetoxBuild/Build/Products/Release-iphoneos/Detox.framework: No such file or directory
~

yarn add [email protected] finishes the detox install without any issue

Steps to Reproduce

Install in a brand new RN project

Detox, Node, Device, Xcode and macOS Versions

  • Detox: latest( 8.1.6)
  • React Native: 0.56.0
  • Node: 10.4.0
  • Device: (didn't get to start the project)
  • Xcode: 9.4.1
  • macOS: 10.13.6

Device and verbose Detox logs

Provided in description

Thank you 🤗

acceptebug

Most helpful comment

@rborn , okay, I'll try to look into it tomorrow.

All 28 comments

I didn't understand from the description, do you mix using yarn and npm in the same project?

Sorry, using yarn OR npm gives the same result.

Okay, so what does that mean?

yarn add [email protected] finishes the detox install without any issue

Did you mean that 8.0.0 has no issue whilst 8.1.6 has?

  • yarn add [email protected] - installs ok, no error
  • yarn add detox - postinstall script fails

@rborn , okay, I'll try to look into it tomorrow.

Can you please attach the full log?

@rborn, I could not reproduce on:

  • macOS High Sierra (10.13.6)
  • React Native: 0.56.0
  • Node: 10.9.0
  • Xcode: 9.3.1

That leaves me with two possibilities:

  • if you are using nvm, could you for the sake of the experiment, install brew install node? I remember a weird bug about that and I don't remember whether it was resolved or not.
  • if that does not apply, could you try out the same with Xcode 9.3 and see if it helps?

We need to narrow down why it happens.

@noomorph I upgraded node to 10.9.0 ( I use n ) not nvm
Sadly I can't downgrade to Xcode 9.3.1 unless you know an non-dangerous way of doing it - I have a setup for another framework that's more fragile and I'm afraid I will break it :(

same result (fails)

@noomorph Check out https://github.com/wix/AppleSimulatorUtils/blob/master/buildForBrew.sh
Here I prepend the export CODE_SIGNING_REQUIRED=NO && env var to disable code-signing requirement. Maybe we can add that to the build script here in Detox too. Unfortunately, I am on Mojave and Xcode 10. Since you are on High Sierra, could you please side-by-side install Xcode 9.4 and try to reproduce? (If you have multiple Xcode versions, you can use sudo xcode-select -s <path_to_xcode> to switch the command-line tools (which Detox uses).

@LeoNatan , sure.

tried this export CODE_SIGNING_REQUIRED=NO && yarn add detox and it still fails, however not sure if it needs to be done in the script itself

I was not able to reproduce this, sorry. Maybe I need to install n instead of nvm... dunno.

I upgraded to Xcode 9.4 and uninstalled node from brew, leaving my environment only with nvm node. Of course, I did detox clean-framework-cache before nom install. No luck :/

Node wouldn't have anything to do with a build failing. It is squarely somewhere in the Xcode build process.

The change happened between version 8.0.0 and 8.1.0 because 8.0.0 is the last one that works.

The build script changed but I'm not sure why the change should introduce such an issue, especially since we cannot reproduce locally.

for what it's worth, this is happening on my machine as well

@dodgecm could you please post the log file? Maybe has more info than mine?

NVM, with Node 8.9.0.
Xcode 9.4.1
Build version 9F2000
Project: Detox example project
I see the exact same behavior as OP where v8.0.0 works, but starting with v8.1.0 it breaks.

I've attached my command line output, but it doesn't seem to be very useful. how are you generating the detox_ios.log file?

node node_modules/detox/scripts/postinstall.js
+++ dirname /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts/build_framework.ios.sh
++ dirname /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts
+ detoxRootPath=/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox
++ node -p 'require('\''/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/package.json'\'').version'
+ detoxVersion=8.1.6
++ echo 8.1.6
++ xcodebuild -version
++ shasum
++ awk '{print $1}'
+ sha1=d179a1f7560289c939ae80cc7ba3d338d9fc4b5c
+ detoxFrameworkDirPath=/Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c
+ detoxFrameworkPath=/Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/Detox.framework
+ main
+ '[' -d /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c ']'
+ '[' '!' -d /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/Detox.framework ']'
+ echo '/Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c was found, but could not find Detox.framework inside it. This means that the Detox framework build process was interrupted.
         deleting /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c and trying to rebuild.'
/Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c was found, but could not find Detox.framework inside it. This means that the Detox framework build process was interrupted.
         deleting /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c and trying to rebuild.
+ rm -rf /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c
+ prepareAndBuildFramework
+ '[' -d /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios ']'
+ detoxSourcePath=/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ extractSources /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ detoxSourcePath=/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ echo 'Extracting Detox sources...'
Extracting Detox sources...
+ mkdir -p /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ tar -xjf /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/Detox-ios-src.tbz -C /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ buildFramework /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ detoxSourcePath=/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ echo 'Building Detox.framework from /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src...'
Building Detox.framework from /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src...
+ mkdir -p /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c
+ /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts/build_universal_framework.sh /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src/Detox.xcodeproj /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/DetoxBuild
child_process.js:624
    throw err;
    ^

Error: Command failed: /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts/build_framework.ios.sh
    at checkExecSyncError (child_process.js:601:13)
    at Object.execFileSync (child_process.js:621:13)
    at Object.<anonymous> (/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts/postinstall.js:2:27)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)

Never mind, figured it out. Looks like the same issue as you.

Signing Identity:     "-"

    /usr/bin/codesign --force --sign - --timestamp=none /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src/Build/Products/Release-iphonesimulator/Detox.framework

** BUILD SUCCEEDED **

cp: /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/DetoxBuild/Build/Products/Release-iphoneos/Detox.framework: No such file or directory

I followed the paths inside the build directory, and it looks like there was a Products/Release-universal folder made, which is empty. Perhaps the new version of xcode changed the folder name for simulator outputs? Based on the path of the Detox.framework that got exported, maybe it's not respecting the Derived data path?

I think I found the issue. Inside my Xcode workspace settings, I had my build location set to "Custom", which was putting the build artifacts inside the project folder's Build directory. When I changed it back to the default setting, npm install ran smoothly again. I'm not sure what change should be made to fix this inside detox, but hopefully this should allow you guys to reproduce this easily.

In order to reproduce it, delete your DerivedData folder (Library/Detox/ios/*) and change your Xcode workspace settings to the values in the second image.

Default setting:
screen shot 2018-08-16 at 5 18 20 pm

Broken setting:
screen shot 2018-08-16 at 5 20 10 pm

Great, thanks! Will look into that next week.

Hopefully, my fix will solve this issue. If this issue gets locked before a new version is out, just open a new issue.

@LeoNatan Trying to test this by installing from git master but npm complains of Can't add "detox": invalid package version undefined. any idea? ☺️

@rborn , try out https://github.com/wix/detox/blob/master/docs/Guide.Contributing.md
Do install via lerna, then a) npm link or b) as a hack, insert your project inside detox/ folder and add it to lerna.json and do learn bootstrap. Anyway, follow the manual.

@noomorph I'll give it a shot, thnx

I just pushed a further commit.
I think I know now what the original issue was. It was not what I assumed. It seems under certain conditions, doing a xcodebuild clean build removes all products, including from different SDKs. So iphoneos is built first, but then the clean for iphonesimulator causes the deletion of the product of iphoneos 🤦‍♂️ Apple and their shit

Was this page helpful?
0 / 5 - 0 ratings