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

☆樱花仙子☆ 提交于 2019-11-27 18:50:20
Saravana Kumar

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

  1. Get ".app" file :

    Command : react-native run-ios --configuration=release

  2. ".app" file path :

    Build/Products/Release/"<Your_Filename>.app"

  3. Convert .app to .ipa :

    a. Create folder Payload.

    b. paste .app file into Payload folder.

    c. compress the Payload folder.

    d. 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>

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

  • 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!