Can an iOS app (built entirely with React Native) be built/run from the command line? PhoneGap has a nice ios-sim utility for doing just that, but I haven't had any luck with it.
If you build the project once using Xcode, then you can close it, run npm start in your project root (to start the packager), fire up the Simulator (maybe using ios-sim). Since you built it once in Xcode, the app will be installed in the simulator so you can just run it and the whole CMD+R refresh process will work.
Fire up the server with:
$ npm start
Build/run the app in the ios simulator:
$ react-native run-ios
Related
npm start
Select a - for android
However, with this, you only have the app running temporarily and have to do it repeatedly to launch it.
Is there a way to permanently install an app by Build -> Install like on Android Studio?
Thank you all in advance.
Well if you wish to permanently install the app on your phone, you will have to generate a production build (.apk file) and install it on your phone.
npx react-native run-android --variant=release
Read this for more clearity regarding builds.
It's unclear if you want to install it to your physical device or not.
In android studio you can press "Build" in the menu and then select build variants, change "app" to release.
Similarly in xcode, you can select build configuration to be on release.
Then you just build the project and you will have a release version of the app on your phone.
I'm trying to create a slider in my react native Android App, and relatively new to React Native. The React Native documentation says their Slider component is deprecated (https://reactnative.dev/docs/slider.html) and directs us to use #react-native-community/slider instead (https://github.com/react-native-community/react-native-slider/blob/master/README.md).
I installed the library in my project directory using npm install #react-native-community/slider --save.
The install succeeded and my versions in my package.json are as follows:
"dependencies": {
"#react-native-community/slider": "^3.0.3",
"react": "16.13.1",
"react-native": "0.63.0" },
I am including the Slider in my source file with import Slider from '#react-native-community/slider';, however when ever I try to actually create a slider in my code with the <Slider> ... </Slider> tags, I get the following compile error:
ERROR Invariant Violation: requireNativeComponent: "RNCSlider" was not found in the UIManager.
I've been banging my head against the wall and can't figure out how to clear the error.
I am on Windows 10 x64 developing for Android.
Thanks in advance!
I've also faced this issue and if you've followed the setup instructions word by word, the solution should be:
Stop the Metro Bundler.
Stop the app on the simulator/physical device.
Run react-native-start.
Run react-native run-android or run the app on your physical device.
Done!
This is what fixed it for me for development on iOS. Hope this can be of help to you on Android as well!
The solution for me was to just run "npx react-native run-android" in my project directory rather than trying to use "npx react-native start". I'm not sure why this works, but it launches the metro server in another console window (using cli.js) rather than in powershell itself. This seems to solve the problem.
Historically I had been launching the app directly from my emulated phone OS, but this didn't work even if I had the metro server running in powershell.
run command in vs code terminal
cd ios
pod install
cd ..
react-native run-ios
or
react-native android
I tried #Californium's method to stop the Metro Bundler, Simulator, and re-run everything, but that didn't work for me. I also tried to link Slider, but that even didn't work for me.
react-native link #react-native-community/slider
I think You need to just
Import Slider form 'react-native'
This worked for me.
You can try all the steps, provided and if those didn't work. Use the slider from react-native.
I followed React Native Official Doc Step By Step from
https://facebook.github.io/react-native/docs/getting-started.html
and initialized a project and got the following files (except splash.js and style.js)
For learning React Native I was following a youtube video and in there the project folder contained some android and ios specific files.
But I ran the project by creating a simple splash screen and it's running on both android or ios file.
As a beginner I'm so confused. So How can i get those files.
For Example,
index.ios.js
Index.android.js
just double check that you follow this instructions https://facebook.github.io/react-native/docs/getting-started.html and not something else.
Now what i am doing is
1) npm install -g react-native-cli
2) react-native init AwesomeProject
3) cd AwesomeProject
4) react-native run-ios
you are using expo if you want native code try Building Projects with Native Code tab on https://facebook.github.io/react-native/docs/getting-started.html#getting-started
Missing android,ios & app folders and index js files
I'm using react native v 0.1.10 in windows 7 OS
We can generate android and ios folder by using upgrade
Run react-native upgrade to generate /ios and /android folders again.
Run react-native link for any native dependency. (if needed)
Finally run
react-native run-ios
or
react-native run-android
Probably you created your project using create-react-native-app, which is an even more simplified toolchain.
You should probably eject if you need android/ios native configs or something.
Please take a look at this doc: https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md
Try this to generate the Android and iOS folder without change version
react-native eject
react-native link
Install a new file using powershell instead of cmd.
Run following commands
1. npx react-native eject
After running above command you can see output in console as follows
info Generating the iOS folder.
info Generating the Android folder.
Next below command
2. npx react-native run-android
Try update ur nodejs and npm to the latest version then run everything again starting from init
npm run eject
next we will get some couple of questions,
? how would you like to eject from create-react-native-app
React-Native : I'd like a regular react native project
? What should your app appear as on a users's home screen? _Your wish____
? What should your Android Studio and Xcode projects be called? rncourse
After Ejected Successfully the project structure will change, added folders android and ios.
happy coding
I'm trying to simulate my app on ios simulator with ionic. But when I run:
ionic build ios
ionic emulate ios
My app doesn't appear on the simulator. What should I do?
You need to install IOS-Sim tool.
The ios-sim tool is a command-line utility that launches an iOS application on the iOS Simulator.
Apply this command on terminal window:
$ sudo npm install ios-sim -g
Make sure that you have added the iOS platform to the project and verify that you have the iOS-Sim tool. If this is the problem you should a message that you are missing any of those two in the terminal.
if you are using visual studio, you need to configure the remote ios agent.
follow this documentation https://msdn.microsoft.com/library/dn757054.aspx#ios to configure and test you application
Sometimes, an ionic app can take a really long time to load on the simulator. First try waiting.
Second, if it still doesn't load, know that the simulator is a lot pickier about what it will run and not run than the browser. Check if you app works in the browser. Try a different browser (such as Firefox). If it does not, debug from there. If it does work in the browser, run your code through a linter to find that one semi-colon that your browser didn't care about.
Try start do it on xcode(in each my ionic/cordova project i have to use some native solutions to build application for iOS i use xcode for android i use android studio)
I know that different platform need some hours of adapt but this knowledge is very important
Try remove and add platform again.
ionic platform rm ios
and
ionic platform add ios
simply use following commands to build and run your ionic app respectively.
ionic cordova build ios
ionic cordova run ios