49

I am trying to run the release build directly from the terminal and I did not found an option to do that.

From XCode what is required to do is:

Product -> Scheme -> Edit Scheme (cmd + <), make sure you're in the Run tab from the side, and set the Build Configuration dropdown to release.

http://facebook.github.io/react-native/docs/running-on-device-ios.html#building-your-app-for-production

There is any option available from the react-native-cli to do the same? Something like react-native run-ios -configuration Release?

My objective is to generate a build that does not require the server being running to provide to the QA team for instance.

Sandro Machado
  • 9,921
  • 4
  • 36
  • 57

6 Answers6

138

I did a PR to the React Native project to allow this feature. The PR can be check here: https://github.com/facebook/react-native/commit/ca7cbdee858e84c4a74a2d9c7be151f5cfdcfbfe

So, in the future, to run a release build from terminal you just only need to type the following command: npx react-native run-ios --configuration Release

If you want run your project on a real device use --device parameter:

npx react-native run-ios --configuration Release --device "Your Device Name"
Erick Maeda
  • 329
  • 1
  • 10
Sandro Machado
  • 9,921
  • 4
  • 36
  • 57
  • 1
    Thanks. Need to upgrade to v0.39+ though. – Hulvej Dec 17 '16 at 13:11
  • Thanks so much for this PR, can you please add some more words on this subject. I was able to release to Android easily following this - https://facebook.github.io/react-native/docs/signed-apk-android.html - however after I run `react-native run-ios --configuration Release` I don't know what to do :( I can't even find the binary it created so I can install it on my device. :( I was avoiding fastlane as I wanted to learn the manual way for my first time. – Noitidart Jun 08 '17 at 11:46
  • 1
    Hum, to generate the binary to upload to AppStore/ install in your device you need to do the following: https://stackoverflow.com/a/42130914/3482000 – Sandro Machado Jun 08 '17 at 13:32
  • 2
    For me it runs it on emulator. How can I target my device? – Peter Borbas Jun 19 '18 at 07:43
  • what file is outputted by this command which can be uploaded to the app store? – pstanton Jul 25 '18 at 07:38
  • 1
    Doesn't work. `An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):` – Green Aug 17 '18 at 10:11
  • @pborbas use `--device` parameter. – Olcay Ertaş Mar 11 '19 at 09:37
4

May 2023

Just an update: configuration has been deprecated in favor of mode.

npx react-native run-ios --mode Release

The Grindfather
  • 152
  • 2
  • 3
  • 12
2

Checked right now, and it works:

npx react-native run-ios --configuration Release --simulator="iPhone 14"

Kamil Sarna
  • 5,993
  • 1
  • 32
  • 22
0

As far as I know, react native doesn't come with something like that out-of-the-box.

But because your react-native app is also a plain Objective-C app with react-native on the inside, you can re-use existing tools to perform the build/packaging for you.

Check the following article for example on how to automate your build using fastlane.

https://shift.infinite.red/simple-react-native-ios-releases-4c28bb53a97b#.i1otlntat

Thomas
  • 7,933
  • 4
  • 37
  • 45
0

The react-native script that handles the bundling is here:

  ./node_modules/react-native/scripts/react-native-xcode.sh

and it basically does this:

  node "./node_modules/react-native/cli.js" bundle  --entry-file "index.js" --platform ios --dev false --reset-cache --bundle-output "./app.app/main.jsbundle" --assets-dest "./app.app"

where bundle-output and asset-dest would normally point to your xcode build output. For example:

~/Library/Developer/Xcode/DerivedData/MyApp-enjmlvtpwwpnsxanntxwgpneywcy/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphonesimulator/MyApp.app
Lee Irvine
  • 3,057
  • 1
  • 15
  • 12
0

Simple and easy just run the command

npx react-native run-ios --mode Release
Zeeshan Ansari
  • 9,657
  • 3
  • 26
  • 27