Alisher Musurmonv
Alisher Musurmonv

Reputation: 845

How to publish a react native as a apk file or ios file?

I have been learning React Native for a while by watching video tutorials. The instructors are teaching how to code and run the project in simulator but no one ever mentioned or showed how to publish the local projects as a production app. I researched and checked official React Native documentation but I could not figure out how to publish

The question is how can I make a downloadable, installable single file mobile application to use in my mobile phone.

Please, share any useful video tutorial or documentation. Thank you in advance.

Upvotes: 2

Views: 12983

Answers (2)

soutot
soutot

Reputation: 3671

ANDROID

You must generate a private key by running

$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

Then you have to set the generated file my-release-key.keystore under android/app in your project.

Edit the file ~/.gradle/gradle.properties as following

MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=[YOUR PASSWORD]
MYAPP_RELEASE_KEY_PASSWORD=[YOUR PASSWORD]

Now edit android/app/build.gradle as following:

android {
     ...
     defaultConfig { ... }
     signingConfigs {
         release {
             if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                 storeFile file(MYAPP_RELEASE_STORE_FILE)
                 storePassword MYAPP_RELEASE_STORE_PASSWORD
                 keyAlias MYAPP_RELEASE_KEY_ALIAS
                 keyPassword MYAPP_RELEASE_KEY_PASSWORD
             }
         }
     }
     buildTypes {
         release {
             ...
             signingConfig signingConfigs.release
         }
     } }

And in your terminal run cd android && ./gradlew assembleRelease

Your APK will be generated inside this directory android/app/build/outputs/apk/ as app-release.apk

To install it in your device, run: react-native run-android --variant=release

More info in the official docs: https://facebook.github.io/react-native/docs/signed-apk-android.html

IOS

You must have an Apple Developer Account https://developer.apple.com/account/

  1. Open Xcode and sign in with your developer account

  2. Build your project

  3. From toolabar Select Product > Archive

  4. Click on Validate

  5. Click on Export

  6. Download IPA file

  7. From toolabar Click on Xcode > Open Developer Tool > Application Loader

  8. Click on Deliver App

  9. Select the downloaded IPA file

  10. Wait a few minutes and your app will be available on AppStore Connect

  11. From there you can use Test Flight to distribute your app to a test team.

  12. Download Test Flight App in your device

  13. After you set up a test team, all testers will be available to download the app through Test Flight

More info here: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html

Hope it helps

Upvotes: 12

Pradeep Kumar
Pradeep Kumar

Reputation: 686

You should generate a Signed APK file for android while publishing on Play store.

Click here to see full instruction of how to create signed APK file.

For iOS Click here

Upvotes: 0

Related Questions