Search code examples
iosxcodereact-nativereact-native-cli

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.


Solution

  • 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