I have been reading React Native's documentation as well as forums, and answers to similar questions but cannot figure out how to run my application on my device.
I have tried what was mentioned in this question " Run react-native application on iOS device directly from command line? ", as well as deleting the build folder from the ios directory and rerunning the script. I will run this command npm run ios --device "Anthony's iPhone"
, but it results in this Launching iPhone 6 (iOS 11.3)...
I have also tried running npm run ios --simulator "iPhone 5s"
but again I get Launching iPhone 6 (iOS 11.3)...
. I am not sure where to go from here, more information can be seen below. Of course, the simulator is always launched and functions properly but I would like to control whether it runs on a device or in which simulator.
Anthonys-MacBook-Pro:fitness-app anthonysette$ npm run ios --device "Anthony’s iPhone"
> FitnessApp@0.1.0 ios /Users/anthonysette/Documents/fitness-app
> react-native run-ios "Anthony’s iPhone"
Scanning folders for symlinks in /Users/anthonysette/Documents/fitness-app/node_modules (15ms)
Found Xcode workspace FitnessApp.xcworkspace
Launching iPhone 6 (iOS 11.3)...
Building using "xcodebuild -workspace FitnessApp.xcworkspace -configuration Debug -scheme FitnessApp -destination id=28DE4434-4D1A-4B5E-8C16-0AC2C101F8E0 -derivedDataPath build"
User defaults from command line:
Edit: Added info from package.json
My package.json has a portion called scripts which contains the following
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"rename": "node ./bin/rename.js",
"start": "react-native start",
"test": "jest"
},
The npm run ios
as defined your script will run react-native run-ios
. Therefore you can either install react-native cli
globally and use
react-native run-ios --device "Anthony’s iPhone"
or add a new script to your package.json
as
"ios-device": "react-native run-ios --device"
and run npm run ios-device "Anthony's iPhone"
I would suggest you to install " create-react-native-app " to create react native app. You can run your app in your device through " expo ". Run your app with " npm start " command. Download and install expo in your phone and scan the generated QR code. It also supports hot reload.
Note - Make sure your computer and phone are on same network.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.