Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native run-ios can not find any simulator

I have been facing an issue where 'react-native run-ios' can not start, regardless of the simulator I add to the --simulator argument. XCode has the correct location for the 'command line tools'

I am always getting the error: Could not find iPhone X simulator

Error: Could not find iPhone X simulator
    at resolve (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
    at new Promise (<anonymous>)
    at runOnSimulator (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
    at Object.runIOS [as func] (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
    at Promise.resolve.then (/Users/eric/.../swim/node_modules/react-native/local-cli/cliEntry.js:117:22)

react-native info

>   React Native Environment Info:
>     System:
>       OS: macOS 10.14.2
>       CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
>       Memory: 6.76 GB / 32.00 GB
>       Shell: 3.2.57 - /bin/bash
>     Binaries:
>       Node: 10.15.0 - /usr/local/bin/node
>       Yarn: 1.13.0 - /usr/local/bin/yarn
>       npm: 6.4.1 - /usr/local/bin/npm
>     SDKs:
>       iOS SDK:
>         Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
>     IDEs:
>       Android Studio: 3.1 AI-173.4819257
>       Xcode: 10.1/10B61 - /usr/bin/xcodebuild
>     npmPackages:
>       react: 16.6.3 => 16.6.3 
>       react-native: 0.57.8 => 0.57.8 
>     npmGlobalPackages:
>       create-react-native-app: 1.0.0
>       react-native-cli: 2.0.1
>       react-native-git-upgrade: 0.2.7
like image 583
eric f. Avatar asked Feb 03 '19 21:02

eric f.


People also ask

How do I run React Native on specific iOS simulator?

You can specify the device the simulator should run with the --simulator flag, followed by the device name as a string. The default is "iPhone 13" . If you wish to run your app on an iPhone SE (2nd generation), run npx react-native run-ios --simulator='iPhone SE (2nd generation)' .

Can we run iOS simulator without Xcode?

Launching the Simulator, though, always requires opening Xcode and going to Developer Tools. Because the Simulator. app is embedded within the Xcode app bundle, apps like LaunchBar won't find it to index it.

How do I run a React Native app on iOS Windows?

Expo allows us to build for both Android and iOS on Windows, Mac and Linux. You can run your React Native app on a physical device without setting up the development environment. All you need to do is download the Expo Go app, run expo start and then scan the QR code that shows up.


3 Answers

Update

It is fixed in v1.9.8.

Update cli is the easy solution

npm install -g react-native-cli@latest

This issue is fixed but not released yet. https://github.com/react-native-community/react-native-cli/pull/274

So it can be solved temporarily to fix the file below.

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

Change this line

if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {

to

if (!version.includes('iOS') && !version.includes('tvOS')) {

Do not forget apply this again when you reinstall packages.

like image 129
Jeff Gu Kang Avatar answered Oct 10 '22 04:10

Jeff Gu Kang


I tried like below

Open Xcode. Then Preferences -> Select Components in Tabs.

Then install any one(or more) of the available simulators on the list. Preferably the recent one at the top.

It solves the problem.

like image 6
Sathishkumar Rakkiyasamy Avatar answered Oct 10 '22 05:10

Sathishkumar Rakkiyasamy


I've found a temporary fix:

In the following file:

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

...change line 42 to:

if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('tvOS')) {
like image 25
eric f. Avatar answered Oct 10 '22 05:10

eric f.