1

How to run react native app in iOS Stimulator?

I'm using npm run ios but I'm getting this error missing srcipt: ios

How to solve this?

enter image description here

Nah
  • 1,690
  • 2
  • 26
  • 46
Lester
  • 701
  • 1
  • 9
  • 47

3 Answers3

3

You can run your project with just simple

react-native run-ios

And if you want to run on any particular simulator device run this

react-native run-ios --simulator="iPhone 6s" // Check your available devices
Kirankumar Dafda
  • 2,354
  • 5
  • 29
  • 56
  • 1
    https://stackoverflow.com/questions/37189081/react-native-command-not-found check this may b you are missing something while setting up react native – Kirankumar Dafda May 31 '18 at 11:35
  • Oh, I think because I'm using `npm install exp` and `exp init myproject` to create the project, so that it's not react native project? how to use exp and react-native at the same time? – Lester Jun 01 '18 at 02:36
0

Usually we have package.json with any command line scripts, for example:

"scripts": {
    "test": "node ./node_modules/jest/bin/jest.js --watchAll",
    "dev": "exp start --dev --lan",
    "build-android": "exp build:android",
    "build-ios": "exp build:ios"
},

In your case, I am not sure from which source you initialized or cloned your project. But you will need to add and you can add without any issue the missing scripts. You can label them by anything, e.g. "test" can be named by "mytest".

The example I have given above, you can see command exp, this is a module that you will need to install globally in order to run this command.

using npm install -g exp command. Then you can run the custom added scripts.

Find anything confusing, ask again.

Nah
  • 1,690
  • 2
  • 26
  • 46
  • is that mean I have to copy the scripts and paste it on my package.json. Then run `npm install -g exp` on terminal? – Lester May 31 '18 at 10:38
  • Yes, during development we use `dev` script that you see in example, so you can run on your emulator or mobile device. Now if you want to make a final build `.apk` for *Android* and `.ipa` for *iOS* then we use `build-ios` script to make a final build for developed app. – Nah May 31 '18 at 11:43
0

Did you try running react-native run-ios?

https://facebook.github.io/react-native/docs/running-on-simulator-ios.html

If that doesn't work, you can always open project-directory/app/ios/[your-project-name].xcodeproj in xcode, and run the simulator in xcode directly.

Jordan Daniels
  • 4,896
  • 1
  • 19
  • 29