Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run my React Native application on my device rather than in IPhone 6 simulator?

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"

> [email protected] 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"
  },
like image 266
Anthony Sette Avatar asked Sep 07 '25 03:09

Anthony Sette


1 Answers

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"

like image 85
Pritish Vaidya Avatar answered Sep 09 '25 20:09

Pritish Vaidya