Creating Android and iOS app from react-native - react-native

I have created one react-native app using expo and atom editor. It's running fine in android device and iOS simulator but with the help of expo. What I want is to generate Apk(debug) so that I can directly run on device. How can I do it ? I followed this(Dmitry Mugtasimov's answer). should I run all those command inside project folder ? Also I don't find index.js file inside my project folder. Also if someone know how to run on iOS simulator by creating app like file(don't know what is that in Ios because from android background). Please help, thanks

Since you have used Expo to develop your react-native app you can build the android app by going to the project folder and running the bellow command in the terminal
expo build:android
The building process will take around 5-10 minutes. When your build is done, expo build:status will give you your .apk file url. If not, it will say your build is still in progress and to try again later.
Also to build the iOS app you can run,
expo build:ios
To build the iOS standalone app you will need to have an Apple Developer account, but for Android standalone app you don't need a Google Play Developer account.
For the above commands to work you need to have expo-cli installed, For this you can run the bellow command,
npm install -g expo-cli
More Info: https://docs.expo.io/versions/latest/distribution/building-standalone-apps/
If you don't have an Apple Developer Account. You can build the iOS
standalone simulator build using the command,
expo build:ios -t simulator
And then wait for build to finish then download and unpack YourAppName.tar.gz. Then, start the iOS simulator and run xcrun simctl install booted YourAppName.app to run the .ica file.
More info: Expo / React-Native, Is it there a way to test-run standalone iOS apps on a device/simulator?

Related

npx expo run:android -> CommandError: No development build (<package>) for this project is installed

After running npx expo run:android once, the app was pushed to the device and the app started up.
I then uninstalled the app on the device and then when I run npx expo run:android once again I get the error:
CommandError: No development build (<package-name>) for this project is installed. Please make and install a development build on the device first.
Learn more: https://docs.expo.dev/development/build/
I started another dummy project with another package name and the same thing can be reproduced after uninstalling once.
The built app is not installing once again on the Android device and then starting up.
The docs referenced in the error states https://docs.expo.dev/development/build/#locally-with-xcode-and-android-studio the following:
If you are comfortable setting up Xcode, Android Studio, and related dependencies, you can build and distribute your app the same as any other iOS or Android app.
The npx expo run commands will create a new build, install it on to your emulator or device, and start running it.
Not sure what I am doing wrong. Any help is appreciated.

APK of react-native app shows blank screen

I have built a react-native app which works perfectly fine in development, but when I generate the APK with expo build:android, it doesn't work. If I load the app on my android device, the splash screen is displayed for a few moments and then it just shows a blank screen. I am unsure how to check what the error is when using the apk. How do I do so?
The issue could be with the SDK version. Check your device API level and the SDK version your building with.
You could set up a ADB (Android Debug Bridge) and install the apk onto a device/emulator. There you have a number of options for debugging.
Edit:
If there isn't any android specific code that uses the API then you can ignore what I said before.
Uninstall the app on your device. Settings > Apps > [Your App] > Uninstall
In your development run 'expo start'
If dev is working, then run 'expo start --no-dev --minify'
If that works then you can build 'expo build:android'
Install apk on your device || with ADB preferably
Information need for further troubleshooting:-
Device Version [Found on device Settings>System>About]
Expo SDK [Found in app.json]
ADB logs

React Native Expo app - unable to open app in iOS emulator

I want to run my React Native app in the iOS emulator. Here is what I done so far:
I installed XCode, along with its command line tools, and can bring up the emulator without issue.
I created an empty React Native app using the Expo CLI, per the instructions here. https://facebook.github.io/react-native/docs/getting-started. I am running on Node v10.0.0 on a Mac.
Afterwards I install all the necessary dependencies.
I then run "sudo npm run ios". This fires up the Metro Bundler as well as the iOS simulator. The Simulator loads up after about 5 minutes of waiting, but my app does not start up.
What am I missing here?
I should note that I prefer to stick with Expo, so I'd prefer not to have to eject.

How can I install a React Native app without releasing it to any store?

I wanna be able to use my app on my iPhone or my Android phone without the need of releasing it to App Store or Google Play Store.
or just use EXPO tools if you are open to using expo development environment for react native
If your project is based on React-Native-CLI and your development environment is all set-up then just run command 'react-native run-android' in the terminal. It will generate a debug apk file which you can be found in the directory:
android > app > build > outputs > apk > debug > app-debug.apk
You can directly install this debug apk in your android phone by connecting the device in the debugging mode and run the above command!
In Xcode, add your Apple ID to Accounts preferences, described in
Adding Your Apple ID Account in Xcode.
In the project navigator, select the project and your target to
display the project editor.
Click General and choose your name from the Team pop-up menu.
Connect the device to your Mac and choose your device from the Scheme
toolbar menu.
Below the Team pop-up menu, click Fix Issue.
Xcode creates a free provisioning profile for you and the warning text
under the Team pop-up menu disappears.
Click the Run button.
Xcode installs the app on the device before launching the app.
Test iOS app on device without apple developer program or jailbreak
For IOS you must have a developer account firstly. And then, you can send your app to itunesconnect and get the app from testflight. Or You can run your ios app on device by using cable. But you dont run your app in developer mode.
For android you just need get the apk from android studio. But some steps there are. Follow this steps for get the apk.
How can I generate an apk that can run without server with react-native?
You can Side load your react native app in iPhone or iPad using Xcode
Open your_projectname.xcworkspace from ios folder in Xcode
XCode - Choose your destination device simulator or device from
Product -> Destination -> Select the device
Create a Temporary provision profile From project Target -> Signing
& Capabilities (Required only for physical device, for simulator don't
require this)
Build and Run your project
React Native's official site has a guide on how to install your app without releasing it.
The tl;dr is as follows:
For ios:
cd AwesomeProject
react-native run-ios
For android:
cd AwesomeProject
react-native run-android

Expo detached app, generate iOS simulator build for Facebook App Review

How can I set publishedURL for developmentURL in “EXBuildConstants.plist” as localhost URL will not work with facebbok app review process?
I am building Expo detached app but I need to generate simulator build for Facebook App review.
Everytime “EXBuildConstants.plist” is updating automatically so my simulator build is not working without running Expo.
It's answered on Expo forum
Change in xcode, go to Product-> Scheme->edit Scheme and change build configuration to Release.
Non-Ejected Method
If you'd like to avoid ejecting an Expo "managed" project, you can follow these directions in order to generate the Simulator build (*.app).
The steps from the link are as follows:
Build your expo project with the simulator flag by running expo build:ios -t simulator.
Download the tarball with the link given upon completion when running expo build:status.
Unpack the tar.gz by running tar -xvzf your-app.tar.gz. This will generate the Simulator build file.
Please note the link for the compressed file will be the last thing logged to your terminal when building your app.
After that, you would just zip the simulator build as mention here:
The steps for zipping the build file are as follows:
Run ditto -ck --sequesterRsrc --keepParent `ls -1 -d -t src/*.app | head -n 1` destination/build.zip, where src/*.app is the path the the simulator build file, and destination/build.zip is the destination.