Reputation: 4066
I am using react-native version 0.57.7
. How to create .ipa
file from react-native app
using command line.
I followed some stack-overflow answers(as an example) on how to create .ipa
file from a react-native app so that I can install it in my Iphone and test it.
The answer's I found are either too old or do not have same directory structure as my react native app version 0.57.7
.
Could you please tell me how to generate .ipa
file in react-native
version 0.57.7
for testing it on iphone.
Upvotes: 2
Views: 4442
Reputation: 332
Andrew has the right answer, but if you are going to end up doing a lot of deployments, I would highly recommend using Fastlane. Once you learn fastlane, it will take a lot of the headaches away from the ios deployment process. I made a youtube video on this that talks about the manual process and how fastlane makes it automates each step for you.
I hope this helps!
Upvotes: 0
Reputation: 28539
If you have the provisioning profiles sorted then it is fairly straight forward. Though to be able to test it on device without it being plugged into the computer you will need either an ad-hoc
or enterprise
provisioning profile.
So you will need the provisioning profile and the distribution certificate that you wish to install on your machine.
Basically you have two commands that you will need to run to create your ipa.
Folder structure
In the root directory for my application I have the following folders
So open a terminal in the root directory of the application and we can begin:
Create the archive
Now there are subtle differences if you use cocoapods or not. You can see the differences here in the two different commands notably that project
is replaced by workspace
and that xcodeproj
is replaced by xcworkspace
.
Choose the one that matches your setup best. The result will be a file called myawesomeapp.xcarchive in the root directory of your application.
No Cocoapods/project
xcodebuild "-project" "ios/myawesomeapp.xcodeproj" "-scheme" "myawesomeapp" "-configuration" "Release" "DEVELOPMENT_TEAM=YOUR_TEAM_ID" "PROVISIONING_PROFILE_SPECIFIER=YOUR_TEAM_ID/myawesomeapp_profile_name" "archive" "-archivePath" "myawesomeapp.xcarchive"
Cocoapods/workspace
xcodebuild "-workspace" "ios/myawesomeapp.xcworkspace" "-scheme" "myawesomeapp" "-configuration" "Release" "DEVELOPMENT_TEAM=YOUR_TEAM_ID" "PROVISIONING_PROFILE_SPECIFIER=YOUR_TEAM_ID/myawesomeapp_profile_name" "archive" "-archivePath" "myawesomeapp.xcarchive"
I like to specify the DEVELOPMENT_TEAM
and the PROVISIONING_PROFILE_SPECIFIER
this is so that the correct provisioning profile is used for the app.
I choose the configuration option of Release
as I personally use distribution profiles so that I can then pass the built ipa to the testing team.
If you haven't done anything fancy to your setup then you can probable just replace the words myaewsomeapp
with the name of your application, and myawesomeapp_profile_name
with the name of your provisioning profile.
Sign the archive
You have to sign the archive so that it will become an ipa. To that you need an export_options.plist
.
<?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>compileBitcode</key>
<false/>
<key>method</key>
<string>ad-hoc</string>
<key>provisioningProfiles</key>
<dict>
<key>com.myawesomeapp</key>
<string>myawesomeapp_profile_name</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Distribution: NAME_OF_YOUR_SIGNING_CERTIFICATE (YOUR_TEAM_ID)</string>
<key>teamID</key>
<string>YOUR_TEAM_ID</string>
</dict>
</plist>
So there are a few key points about this:
Set the method to match what your provisioning profile is for. If it is an ad-hoc profile then ad-hoc should go there. The options are app-store, ad-hoc, enterprise or development.
Change com.myawesomeapp
to the bundle identifier of your application. Change my_awesomeapp_profile_name
to be the name of your provisioning profile. Add the name of the signing certificate that you are using. Finally, add YOUR_TEAM_ID
Once you have created the export_options.plist and saved it in the root directory of your application you can then run the next command in the terminal:
xcodebuild "-exportArchive" "-archivePath" "myawesomeapp.xcarchive" "-exportPath" "./" "-exportOptionsPlist" "export_options.plist"
This will then sign the ipa for you and produce a few other files, you may prefer to write to a subdirectory in your application directory rather than the root.
Once you have your ipa you can then install it on your iPhone using Xcode.
As with everything, your setup may differ from mine. That being said this is the method that I use locally, and the method that I use on our CI. It works for us, hopefully it will help you create your ipa.
More information about building can be found at https://developer.apple.com/library/archive/technotes/tn2339/_index.html.
Although it is no longer updated, they go into more detail about what everything does and looking at the offical docs is a good place to start.
Upvotes: 2