facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.23k stars 24.33k forks source link

Build stops without errors when building for release #12182

Closed Naoto-Ida closed 7 years ago

Naoto-Ida commented 7 years ago

Description

When building for Release scheme on Xcode, the build stops progressing without any warnings or alerts. Code builds fine on Debug Release.

Before adding my JS it would build for Release scene without issues. I am using Relay in my code with the required plugins which query a local GraphQL implementation which is available at build time.

Reproduction

  1. react-native init AppName to start with clean React Native proj.
  2. Move JS over to new project.
  3. Run Debug build in Xcode -> Finishes fine.
  4. Go into AppName -> Edit Scheme, change Build Configuration to Release, uncheck Debug executable.
  5. Build output shows following:
// .. all the project libs are done

Run custom shell script 'Bundle React Native code and images'
+ DEST=/Users/Adi/Library/Developer/Xcode/DerivedData/AppName-cykpqtemgicwudggytkcuydyxjyg/Build/Products/Release-iphoneos/AppName.app
+ [[ Release = \D\e\b\u\g ]]
+ BUNDLE_FILE=/Users/Adi/Library/Developer/Xcode/DerivedData/AppName-cykpqtemgicwudggytkcuydyxjyg/Build/Products/Release-iphoneos/AppName.app/main.jsbundle
+ node /Users/Adi/Documents/work/react-native/AppName/node_modules/react-native/local-cli/cli.js bundle --entry-file index.ios.js --platform ios --dev false --reset-cache --bundle-output /Users/Adi/Library/Developer/Xcode/DerivedData/AppName-cykpqtemgicwudggytkcuydyxjyg/Build/Products/Release-iphoneos/AppName.app/main.jsbundle --assets-dest /Users/Adi/Library/Developer/Xcode/DerivedData/AppName-cykpqtemgicwudggytkcuydyxjyg/Build/Products/Release-iphoneos/AppName.app
Loading dependency graph, done.
Warning: The transform cache was reset.
[BABEL] Note: The code generator has deoptimised the styling of "/Users/Adi/Documents/work/react-native/AppName/node_modules/lodash/lodash.js" as it exceeds the max of "500KB".
bundle: start
bundle: finish
bundle: Writing bundle output to: /Users/Adi/Library/Developer/Xcode/DerivedData/AppName-cykpqtemgicwudggytkcuydyxjyg/Build/Products/Release-iphoneos/AppName.app/main.jsbundle
bundle: Copying 30 asset files
bundle: Done writing bundle output
bundle: Done copying assets
+ [[ ! -n false ]]

// Here, I think it should output `Touch AppName.app`, but never does...

I'm not sure what this + [[ ! -n false ]] at the end is. My Terminal is opened with the packager, and the output is as follows:

Looking for JS files in
   /Users/Adi/Documents/work/react-native/AppName 

Loading dependency graph...
React packager ready.

Loading dependency graph, done.

Solution

I would like to know how I can debug this so that I can figure out at what is preventing the progress of the build.

Additional Information

Naoto-Ida commented 7 years ago

So a workaround for this now was to run: react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output iOS/main.jsbundle

Then remove the Bundle React Native code and images script in Xcode. I'd do a Release build and it would finish successfully. Nothing in the app seems to be breaking. What could this be? A problem with the bundle script?

taiki-t commented 7 years ago

When building for Release scheme on Xcode, the build stops progressing without any warnings or alerts. Code builds fine on Debug Release. I am using Relay in my code with the required plugins

Same here.

I was loading GrapqhQL schema via network in a babel plugin (cf) which runs when react-native packeger runs. This logic was working well in 0.38.0 and as I upgraded to 0.42.0 it became unstable.

In my case, switching from loading the schema via network to loading from a local file made build great again.

I guess, in my case, nodejs process forks when bundling so fetching resources via network doesn't work well in certain situations. macOS asked me several times to allow nodejs to access network and server received same requests several times while bundling so I just thought something could go wrong.

Naoto-Ida commented 7 years ago

@taiki-t So shall we close this? We seem to have found a workaround, but doesn't seem to be affecting others (but I'm pretty sure GraphQL is being used a lot for serving data to RN apps...).

taiki-t commented 7 years ago

@Naoto-Ida I'm fine with it. I'm happy with my solution. Thank you for considering me.

Naoto-Ida commented 7 years ago

Ok. Hopefully its not just us thats having issues.

jifromz commented 7 years ago

@Naoto-Ida - I tried your solution but I got this error: Script-00DD1BFF1BD5951E006B06BC.sh: (null): bad interpreter: No such file or directory