53

I would try "https://stackoverflow.com/questions/41970435" But I'cant get .ipa file.

Can any one explain how to get the .ipa file?

Mohit Mishra
  • 87
  • 1
  • 10
Saravana Kumar
  • 3,230
  • 7
  • 26
  • 44
  • Possible duplicate: http://stackoverflow.com/questions/34933439/how-to-build-react-native-ios-app-get-an-app-file-and-deploy-to-device – eden Feb 08 '17 at 15:41
  • Possible duplicate of [How to build React Native iOS app, get an .app file and deploy to device?](http://stackoverflow.com/questions/34933439/how-to-build-react-native-ios-app-get-an-app-file-and-deploy-to-device) – eden Feb 08 '17 at 15:41
  • This is not a duplicate of the above question because the answer on that question is out of date; the details have changed since the question was asked. – Jules Mar 29 '18 at 01:20
  • Possible deplicate: https://stackoverflow.com/questions/35476349/how-to-build-ipa-for-react-native – Dean Meehan Jul 31 '18 at 08:46

3 Answers3

73
  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.
Dorian
  • 7,749
  • 4
  • 38
  • 57
Saravana Kumar
  • 3,230
  • 7
  • 26
  • 44
  • 2
    Getting an error about provisioning profile and build size is 5 times large then Xcode build. – RANVIR GORAI Mar 12 '18 at 10:11
  • @RANVIRGORAI I didn't face issue like that. Could you attach your error dump . – Saravana Kumar Mar 13 '18 at 08:25
  • Doesn't work. `An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):` – Green Aug 17 '18 at 10:00
  • 65
    What is this witchcraft? – wvicioso Oct 28 '19 at 07:16
  • 2
    I got this error when I upload the ipa from transport "ERROR ITMS-90174: "Missing Provisioning Profile - Apps must contain a provisioning profile in a file named embedded.mobileprovision." – Alex Poon May 25 '20 at 05:55
  • 4
    This Build/Products/Release/".app" path does not exist. And what do you mean by Payload folder? – Kasra May 27 '20 at 15:53
  • 2
    I can't find the Build folder to find Build/Products/Release/".app". where to find? – preston Jun 11 '20 at 14:22
  • 7
    @preston look at the CLI after running `react-native run-ios --configuration=release` if everything is fine you'll have the following line `info Installing "/Users/""/Library/Developer/Xcode/DerivedData/""-gpyqutyfhaccnvgoneubfmtbglgw/Build/Products/Release-iphonesimulator/"".app"` that's the release. But my question is that how do I compress Payload ? Is it a simple zip compression or another and specific one ? – Khalil Hamani Jun 17 '20 at 12:54
  • @KhalilHamani yes, just compress, command line zip -r or UI normally. Change the extension .zip to .ipa in the file details. – Carla Camargo Aug 05 '20 at 20:27
  • 3
    on my system this command doesn't generate an .app file, it only starts the app in the iOS emulator (react-native 0.63.2) – Devis L. Nov 12 '20 at 01:29
  • 1
    when I open it in iPhone its opening as .zip file. – Zeeshan Ahmad Khalil Mar 18 '21 at 08:27
  • 1
    I followed all the steps and could upload the ipa to the device but when trying to start it I got a "This app cannot be installed because its integrity could not be verified." – Zhengqian Kuang Feb 20 '22 at 03:56
23
  • 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

aleena1995
  • 231
  • 2
  • 5
  • After following these steps and successfully creating an ipa, I can no longer run the app in debug through the iOS simulator, any advice @aleena1995 – Arthur Apr 08 '19 at 12:38
  • Did you change Scheme to DEBUG and jsCodeLocation back to old one?@Arthur – aleena1995 Apr 09 '19 at 13:11
  • Yeah I ended up reverting all the changes I had, is there a simple way to have both options and be able to bounce from debug and release builds? My current solution is to just keep debug, do all the changes for release, build, then revert – Arthur Apr 09 '19 at 17:33
  • You can use the following code so that the jsCodeLocation will be selected depending on build configuration. Please check the updated solution @Arthur – aleena1995 Apr 11 '19 at 05:51
  • @aleena1995 Is there any limitations to generating IPA this way? Will the app expire after a fixed amount of time? – Chan Jing Hong Jun 29 '19 at 04:36
  • It works, that's very nice. But when I run the ipa, I get the error "This app cannot be installed because its integrity could not be verified." – Houman Mar 30 '23 at 08:56
13

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

Jesse Hill
  • 1,624
  • 1
  • 8
  • 17
agenthunt
  • 8,450
  • 3
  • 30
  • 26
  • 1
    Is this the only way that we can export an IPA via Command Line? Or do we get any integrated command line option with react-native? – Vighnesh Pai Mar 09 '18 at 04:34
  • As of now, the options with react-native only build `.app` as pointed out by the other answer – agenthunt Mar 10 '18 at 05:45