How to build .ipa application for react-native-ios?

  • Delete localhost item from info.plist

    App transport security settings -> Exception domains

  • Bundle ios

    react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
    
  • In Xcode

    Products->Scheme->Edit scheme -> Change build configuration to RELEASE

  • In AppDelegate.m 

    Replace

    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
    

    with

    #ifdef DEBUG
      jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
    #else
      jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
    #endif
    
  • Change device -> Generic iOS device

  • Product -> Clean

  • Product -> Build

  • .app file can be found at

    ~/Library/Developer/Xcode/DerivedData/<app name>/Build/Products/Release-iphoneos/<appname>
    
  • Create folder Payload.


  • Paste .app file into Payload folder.


  • Compress the Payload folder.


  • Change the name you want and put extension as .ipa


  1. Get the .app file:

     react-native run-ios --configuration=release
    
  2. .app file path Build/Products/Release/"<Your_Filename>.app".

  3. Convert .app to .ipa :

    • Create folder Payload.
    • paste .app file into Payload folder.
    • compress the Payload folder.
    • change the name you want and put extension as .ipa.

You can run these commands in the ios directory.

xcodebuild clean archive -scheme <Scheme> -configuration Release -archivePath ../builds/<App>.xcarchive DEVELOPMENT_TEAM=<DevTeam> PROVISIONING_PROFILE=<PROVISIONING_PROFILE> CODE_SIGN_IDENTITY=<CODE_SIGN_IDENTITY>
xcodebuild -exportArchive -archivePath ../builds/<App>.xcarchive -exportPath ../builds/ -exportOptionsPlist ./iosExportOptions.plist 

and iosExportOptions.plist can be something like

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>method</key>
  <string>app-store</string>
  <key>teamID</key>
  <string>{TEAM_ID}</string>
</dict>
</plist>

It is important to note that if you are using cocoapods then you need to build using the workspace and not the project. Adding this flag to the first command will make sure you are targeting the workspace -workspace <AppName>.xcworkspace.

You can also checkout fastlane. https://fastlane.tools/

OR

You can fill in all the details such as DEVELOPMENT_TEAM etc in Xcode and Product -> Archive https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html