Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Since upgrading to Xcode 10.2 I can no longer run react-native run-ios through the cli

I upgraded to Xcode 10.2 today, since upgrading I can't run react-native run-ios through the cli:

react-native run-ios --simulator="iPhone X"

Found Xcode workspace a.xcworkspace

Could not find iPhone X simulator

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

If I run xcrun simctl list devices all of the simulators show (Shutdown) (unavailable, runtime profile not found):

iPhone X (7AADFA50-7B57-4A40-8434-9A86F345D7ED) (Shutdown) (unavailable, runtime profile not found)

Has anyone else had this issue with RN since upgrading xcode to 10.2? It still works through Xcode.. but that means opening Xcode.

like image 759
smj2393 Avatar asked Mar 26 '19 18:03

smj2393


People also ask

How run React Native app on physical device iOS?

The first thing to do is to connect your iOS device to your Mac with a USB cable. Open your react native app's directory, navigate to ios folder, and double-click on . xcworkspace file to open the Xcode. Next, open the Product menu, go to Destination, and select your device.

Can react run on iOS?

React Native supports building apps for iOS, Android, and web from a single code base. It's a more affordable technology than Swift, yet it allows creating high-quality apps.


2 Answers

I solved like this ;

Firstly, you need to go this path

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

and then;

You need to change this code

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

with

if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))

I hope, it will be helpful,

ref : https://github.com/facebook/react-native/issues/21498#issuecomment-476621627

like image 83
krnz Avatar answered Sep 27 '22 16:09

krnz


I thought I would add my solution here too, in hopes to help someone. I just upgraded to Mac OS Mojave and I also upgraded to Xcode 10.2. My whole react native project broke, real bad. So then I downgraded Xcode back to 10.1. Then, I started to see this error, in said after running react-native run-ios:

Could not find iPhone X simulator

the above "hack" fixed it by editing the findMatchingSimulator.js file with the updates above.

Then, react-native run-ios got farther, next error was:

:CFBundleIdentifier, does not exist

I fixed this by:

  1. cd node_modules/react-native/third-party/glog* TabEnter
  2. ./configure

Now react-native run-ios works . I hope this helps someone, this was a pain in the @ss.

like image 1
shinercoder Avatar answered Sep 23 '22 16:09

shinercoder