`react-native run-ios` returns Error: Could not find iPhone X simulator

89,225

Solution 1

Edited: I copied your devices section of your output JSON and embedded to my own /node_modules/react-native/local-cli/runIOS/runIOS.js

function runOnSimulator(xcodeProject, args, scheme) {
return new Promise(resolve => {
    try {
        var simulators = {devices section of your json}; //Here
    } catch (e) {
        console.log("e", e);
        throw new Error('Could not parse the simulator list output');
    }

    const selectedSimulator = findMatchingSimulator(simulators, args.simulator);
    console.log("selected", selectedSimulator);
    if (!selectedSimulator) {
        throw new Error(`Could not find ${args.simulator} simulator`);
    }
    ...

And finally, it gave the same error as yours. So I figured out that parsing version of devices different. In your devices, version is;

"com.apple.CoreSimulator.SimRuntime.tvOS-12-1" //for tvOS
"com.apple.CoreSimulator.SimRuntime.iOS-12-1" // for iOS

but in react-native checks this version values like this(/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js);

// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
    continue;
}

So react-native can not recognize.
If we change this code with this;

// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
    continue;
}

the problem was solved. I checked that with your JSON data in my computer and it worked.

Solution 2

To fix this error, simply reinstall project & node modules using npm

npm install

Then it will show a list of warnings, and to fix them use the following command:

npm audit fix

This should fix everything, and allow you to run iOS emulator react-native run-ios

Solution 3

PROBLEM

If you try this with the latest Xcode (11), there is no iPhone X!

Run Simulator by itself, in the top menu, look under Hardware, Device, iOS 13.0. You will see there is:

  • iPhone 8
  • iPhone 8 Plus
  • iPhone XS
  • iPhone XS Max
  • iPhone XR
  • ... and some iPads

When you execute run-ios, react-native is designed to match a requested device.

The internally hard coded default is iPhone X.

The function that tries to match the requested device is in:

/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/findMatchingSimulator.js

This function is designed so you can give it a device, and an optional version number.

If the given device and version cannot be found, it will return a match using the first device in the list by default.

But... in reality, the first device is a watch, and any watch is excluded from matching, so this function will return null.

SOLUTION 1 - Use an existing Xcode device

Run Simulator first by itself, as described above, and make a note of which iPhone or iPad you want.

Then pass this name as an optional argument the the run-ios command line command as follows:

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

SOLUTION 2 - Add New Xcode iOS Device

According to Xcode 11 Release Notes:

"Xcode no longer creates every available iOS simulator device by default. Instead a set of the most commonly used devices are created. To create other devices — or multiple instances of a device — open the Devices window, select Simulators, click the + button, enter a name, and select the relevant device type and OS version. In Terminal, execute the xcrun simctl create command, for example xcrun simctl create "My iPhone 7" "iPhone 7" iOS13.0. (49428617)"

In Xcode, you need to add a new device called "iPhone X".

Also I answered here: React Native Issue #2328

Solution 4

Temporary fix:

Step 1: Open the file /node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

Step 2: Change a line of code, from this:

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

to this:

if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
  continue;
}

Step 3: Run react-native run-ios (you might need to run it twice, and don't forget to kill the Metro Bundler [the console that's running in the background] if it's running from your previous unsuccessful build!)

The problem was that after an update to Xcode - the simulator namespaces were added to the devices' versions list. The React Native build wasn't expecting these namespaces - hence the build break.

Solution 5

after update to Xcode 11 xcrun returns true or false and not YES or NO as before.

goto /node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js and in

find

if (
   simulator.availability !== '(available)' &&
   simulator.isAvailable !== 'YES'
 ) {
  continue;
}

and change it to

if (
   simulator.availability !== '(available)' &&
   simulator.isAvailable !== true
 ) {
  continue;
}
Share:
89,225
Seongmin Choo
Author by

Seongmin Choo

Updated on May 05, 2021

Comments

  • Seongmin Choo
    Seongmin Choo almost 3 years

    whenever I run react-native run-ios, I get

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

    however, when I run on Xcode, it works fine

    {
      "devicetypes" : [
        {
          "name" : "iPhone 4s",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 4s.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-4s"
        },
        {
          "name" : "iPhone 5",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 5.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-5"
        },
        {
          "name" : "iPhone 5s",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 5s.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-5s"
        },
        {
          "name" : "iPhone 6",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6"
        },
        {
          "name" : "iPhone 6 Plus",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6 Plus.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus"
        },
        {
          "name" : "iPhone 6s",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6s.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6s"
        },
        {
          "name" : "iPhone 6s Plus",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 6s Plus.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus"
        },
        {
          "name" : "iPhone 7",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 7.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-7"
        },
        {
          "name" : "iPhone 7 Plus",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 7 Plus.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus"
        },
        {
          "name" : "iPhone 8",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 8.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-8"
        },
        {
          "name" : "iPhone 8 Plus",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 8 Plus.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus"
        },
        {
          "name" : "iPhone SE",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone SE.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-SE"
        },
        {
          "name" : "iPhone X",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone X.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-X"
        },
        {
          "name" : "iPhone Xs",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xs.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XS"
        },
        {
          "name" : "iPhone Xs Max",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xs Max.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max"
        },
        {
          "name" : "iPhone Xʀ",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone Xʀ.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-XR"
        },
        {
          "name" : "iPad 2",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad 2.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-2"
        },
        {
          "name" : "iPad Retina",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Retina.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Retina"
        },
        {
          "name" : "iPad Air",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Air.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Air"
        },
        {
          "name" : "iPad Air 2",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Air 2.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Air-2"
        },
        {
          "name" : "iPad (5th generation)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad (5th generation).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation-"
        },
        {
          "name" : "iPad Pro (9.7-inch)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (9.7-inch).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-"
        },
        {
          "name" : "iPad Pro (12.9-inch)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro"
        },
        {
          "name" : "iPad Pro (12.9-inch) (2nd generation)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch) (2nd generation).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-"
        },
        {
          "name" : "iPad Pro (10.5-inch)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (10.5-inch).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-"
        },
        {
          "name" : "iPad (6th generation)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad (6th generation).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation-"
        },
        {
          "name" : "iPad Pro (11-inch)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (11-inch).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch-"
        },
        {
          "name" : "iPad Pro (12.9-inch) (3rd generation)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/iPad Pro (12.9-inch) (3rd generation).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation-"
        },
        {
          "name" : "Apple TV",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p"
        },
        {
          "name" : "Apple TV 4K",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV 4K.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K"
        },
        {
          "name" : "Apple TV 4K (at 1080p)",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple TV 4K (at 1080p).simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p"
        },
        {
          "name" : "Apple Watch - 38mm",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch - 38mm.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm"
        },
        {
          "name" : "Apple Watch - 42mm",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch - 42mm.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm"
        },
        {
          "name" : "Apple Watch Series 2 - 38mm",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 2 - 38mm.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm"
        },
        {
          "name" : "Apple Watch Series 2 - 42mm",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 2 - 42mm.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm"
        },
        {
          "name" : "Apple Watch Series 3 - 38mm",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 3 - 38mm.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm"
        },
        {
          "name" : "Apple Watch Series 3 - 42mm",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 3 - 42mm.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm"
        },
        {
          "name" : "Apple Watch Series 4 - 40mm",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 4 - 40mm.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-40mm"
        },
        {
          "name" : "Apple Watch Series 4 - 44mm",
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/DeviceTypes\/Apple Watch Series 4 - 44mm.simdevicetype",
          "identifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-44mm"
        }
      ],
      "runtimes" : [
        {
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime",
          "availabilityError" : "",
          "buildversion" : "16B91",
          "availability" : "(available)",
          "isAvailable" : true,
          "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-12-1",
          "version" : "12.1",
          "name" : "iOS 12.1"
        },
        {
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/tvOS.simruntime",
          "availabilityError" : "",
          "buildversion" : "16J602",
          "availability" : "(available)",
          "isAvailable" : true,
          "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-12-1",
          "version" : "12.1",
          "name" : "tvOS 12.1"
        },
        {
          "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Developer\/Library\/CoreSimulator\/Profiles\/Runtimes\/watchOS.simruntime",
          "availabilityError" : "",
          "buildversion" : "16R591",
          "availability" : "(available)",
          "isAvailable" : true,
          "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-5-1",
          "version" : "5.1",
          "name" : "watchOS 5.1"
        }
      ],
      "devices" : {
        "com.apple.CoreSimulator.SimRuntime.watchOS-5-1" : [
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple Watch Series 2 - 38mm",
            "udid" : "01AFDEF7-63B6-465C-A02A-44EE4A07EABA",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple Watch Series 2 - 42mm",
            "udid" : "BE62C985-DEE2-46EC-8962-A582D537EEE0",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple Watch Series 3 - 38mm",
            "udid" : "078BF157-30FA-41D1-94FA-6B1686E03085",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple Watch Series 3 - 42mm",
            "udid" : "E4CE652E-0185-4C59-B965-BED5FCEE7C76",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple Watch Series 4 - 40mm",
            "udid" : "6621323A-A9DE-4BCB-AC97-54C8C33B0158",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple Watch Series 4 - 44mm",
            "udid" : "D89037A3-66A0-43C1-90BA-E7C76CA0D724",
            "availabilityError" : ""
          }
        ],
        "com.apple.CoreSimulator.SimRuntime.tvOS-12-1" : [
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple TV",
            "udid" : "AFAA21B8-BD4A-45EA-B0FF-E9915FE9B926",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple TV 4K",
            "udid" : "EBB88F2E-CFFE-4981-A736-7A7C0B85643D",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "Apple TV 4K (at 1080p)",
            "udid" : "F0B73E8A-986E-447E-B37A-2F46096DEFF6",
            "availabilityError" : ""
          }
        ],
        "com.apple.CoreSimulator.SimRuntime.iOS-12-1" : [
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 5s",
            "udid" : "F870B7FA-6DDA-4336-89AD-68A402844188",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 5s",
            "udid" : "6627ADE5-F8C1-4AE5-BD6F-3AEDDC0B7B63",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 6",
            "udid" : "05574997-ACAD-40CA-A3D7-5624D53F00FA",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 6 Plus",
            "udid" : "93237078-CA6D-4F97-93F9-779809700018",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 6s",
            "udid" : "9B50FE18-4F49-4EA4-80F0-DF498A667D33",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 6s Plus",
            "udid" : "D4640B6D-97DC-4CA1-BE63-C5403159A3D4",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 7",
            "udid" : "6E9EEC00-3291-42B4-B04A-BA3487F9CD5F",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 7 Plus",
            "udid" : "6DA1C3CF-1D1F-4DEF-9B74-2C40D5FB5881",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 8",
            "udid" : "E19386B9-469A-450B-9CD2-B4FE8687DCF9",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone 8 Plus",
            "udid" : "6D36DF76-8ED9-41A2-9E1A-0BA48B92C26E",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone SE",
            "udid" : "EE4818DF-F817-4441-8A1C-BE1B99303E10",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone X",
            "udid" : "85B78A8F-C32B-4493-BDD1-65ECA3F77C86",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone X",
            "udid" : "CA12C337-4F66-4C6C-ACE5-7F7EACCBC39A",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone XS",
            "udid" : "8BBCE315-2F4C-4132-8E53-28AF52401C8E",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone XS Max",
            "udid" : "4E77C62F-AB1F-4EDE-839B-53F70CAFC79E",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPhone XR",
            "udid" : "28D12ABE-3355-4862-960A-0FE5FFE41C7B",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad Air",
            "udid" : "94485C88-BCEB-456A-95DC-5F8C3DA8D181",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad Air 2",
            "udid" : "CF2C787D-A378-4AB9-B334-F7B24E94AF4D",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad (5th generation)",
            "udid" : "DFE602A5-EC68-4585-8AB0-C045A9843D29",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad Pro (9.7-inch)",
            "udid" : "5A3F3EAC-F788-49F1-A753-5D34A9990F0B",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad Pro (12.9-inch)",
            "udid" : "EF6EBE34-0A85-4FF0-8A45-7BA418A0CC0C",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad Pro (12.9-inch) (2nd generation)",
            "udid" : "FBA940F8-FD85-4D5E-A570-EB4F3A56E1F9",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad Pro (10.5-inch)",
            "udid" : "8AE4AAED-ECE0-4984-9679-8D3022064692",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad (6th generation)",
            "udid" : "1121363D-EF49-4AC0-9E46-5C30318A24A2",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad Pro (11-inch)",
            "udid" : "038FECC0-8711-46E3-B601-8F88F2F4AD7D",
            "availabilityError" : ""
          },
          {
            "availability" : "(available)",
            "state" : "Shutdown",
            "isAvailable" : true,
            "name" : "iPad Pro (12.9-inch) (3rd generation)",
            "udid" : "12DC911F-2F45-4767-BC1A-6F1D0C8D9F3D",
            "availabilityError" : ""
          }
        ]
      },
      "pairs" : {
        "C9B69F4A-6A9D-44F3-A6BC-56BFA2F8B83F" : {
          "watch" : {
            "name" : "Apple Watch Series 4 - 44mm",
            "udid" : "D89037A3-66A0-43C1-90BA-E7C76CA0D724",
            "state" : "Shutdown"
          },
          "phone" : {
            "name" : "iPhone XS Max",
            "udid" : "4E77C62F-AB1F-4EDE-839B-53F70CAFC79E",
            "state" : "Shutdown"
          },
          "state" : "(active, disconnected)"
        },
        "5327B65F-29E7-42D0-9861-FF31428F3218" : {
          "watch" : {
            "name" : "Apple Watch Series 4 - 40mm",
            "udid" : "6621323A-A9DE-4BCB-AC97-54C8C33B0158",
            "state" : "Shutdown"
          },
          "phone" : {
            "name" : "iPhone XS",
            "udid" : "8BBCE315-2F4C-4132-8E53-28AF52401C8E",
            "state" : "Shutdown"
          },
          "state" : "(active, disconnected)"
        }
      }
    
  • Kevin Grant
    Kevin Grant about 5 years
    Hate that this worked - anyone have a more permanent solution?
  • Patrik Rikama-Hinnenberg
    Patrik Rikama-Hinnenberg about 5 years
    Same problem here. Is there any permanent solution to avoid nom install backroll. Downgrade to xcode 10.0?
  • Firu
    Firu about 5 years
    Its nothing to do with npm as it will just install or audit node modules
  • Mix Master Mike
    Mix Master Mike about 5 years
    In case anyone was running iPhone XR specifically (ie. react-native run-ios --simulator='iPhone XR'), use the following, react-native run-ios --simulator='iPhone Xʀ'. Using a lowercase r will not work.
  • wbharding
    wbharding about 5 years
    The longer term fix is to await the next release of react-native-cli, where this is fixed github.com/react-native-community/react-native-cli/pull/274
  • RiddlerDev
    RiddlerDev about 5 years
    This fixed it for me... without doing the accepted answer. Thanks!
  • Rob Osborne
    Rob Osborne about 5 years
    @Firu And yet there are at least three of us now for which this was the fix.
  • Gianfranco P.
    Gianfranco P. about 5 years
    this didn't work for me. react-native --version -> react-native-cli: 2.0.1 react-native: 0.57.7 react-native info -> macOS 10.14.4 Platforms: iOS 12.2 Xcode: 10.2/10E125
  • helloworld
    helloworld about 5 years
    This worked for me too.. Too early. It opens up emulator but application building fails :|
  • Dombi Soma
    Dombi Soma about 5 years
    Worked for me too.
  • Bathan
    Bathan almost 5 years
    imho this should be the right answer. Changing node_modules files should not be a valid answer. It will come back to bite you when you trash node_modules folder for any reason.
  • Emon
    Emon almost 5 years
    Worked for me.Thanks.
  • Weisheng Wu
    Weisheng Wu almost 5 years
    I'm glad it worked for you all. Just to clarify, I mean first step : npm install is using npm to reinstall the node modules, not reinstall npm. My apologies on the typo.
  • Augusto Gonzalez
    Augusto Gonzalez almost 5 years
    Permanent solution for this issue? For me it works to upgrade RN to 0.58.6
  • levye
    levye almost 5 years
    npm audit fixchanges my react-native version to 0.59.8 from 0.57.5. Is this the solution or side affect?
  • arled
    arled almost 5 years
    How is this the answer?!?!?!?! you don't mess with plugins like that
  • user781404
    user781404 almost 5 years
    This worked for me as well. Found it different directory. node_modules/@react-native-community/cli/build/commands/runI‌​OS/findMatchingSimul‌​ator.js
  • KlimczakM
    KlimczakM almost 5 years
    @levye side effect, really troublesome by the way.
  • Oliver Dixon
    Oliver Dixon over 4 years
    They changed it again (wtf) /node_modules/@react-native-community/cli-platform-ios/build‌​/commands/runIOS/fin‌​dMatchingSimulator.j‌​s
  • Parth Manaktala
    Parth Manaktala over 4 years
    Thanks a lot, you saved the day. Instead of manually configuring the changes this is the easiest and by far the most accurate solution in case of ios 13+. Personally this should be tagged as the accepted answer.
  • Akio
    Akio over 4 years
    This doesn't work anymore. runIOS folder isn't on react-native folder in node_modules as of today. Any other fix?
  • nosequeldeebee
    nosequeldeebee over 4 years
    this should be the accepted answer, along with a quick explanation of how to change the RN default from iPhone X
  • Akio
    Akio over 4 years
    iOS 13.0 simulators now doesn't include every available devices except for the most used one, you need to manually create them if you want other devices (e.g iPhone 7, iPhone X). Reference is here: developer.apple.com/documentation/xcode_release_notes/…
  • Jay
    Jay over 4 years
    this fixed and should be the primary answer.
  • bergjs
    bergjs over 4 years
    I simply added an iPhone X to the list of available devices directly in XCode. Now it can be found!
  • Chris
    Chris over 4 years
    It's as easy as this, at least for me.
  • Sudhir
    Sudhir over 4 years
    Yes, that's what my issue was that after update to xcode 11 i started getting this error. replacing 'YES' with true did the job.
  • Andrew Newby
    Andrew Newby over 4 years
    @velvetlnk - mine only goes up as far as
  • Forhad
    Forhad over 4 years
    I couldn't find (wtf)
  • Kampai
    Kampai over 4 years
    Yes, this is the actual reason, do not try to edit any files. Thanks a lot.
  • velvetInk
    velvetInk over 4 years
    install any ios versions below 13
  • sospedra
    sospedra over 4 years
    This is the proper 2019 solution 👌
  • Harry Moreno
    Harry Moreno over 4 years
    this should work I think but did not for me, I tried with the relevant simulator open and closed
  • eightyfive
    eightyfive over 4 years
    Definitely the way to go. Ran into 2 small issues tho: 1- Had to pair my new "iPhone X" simulator with an iOS 12.4 runtime 2- Had to replace simulator.isAvailable !== 'YES' with simulator.isAvailable !== true in node_modules/@react-native-community/cli/build/commands/runI‌​OS/findMatchingSimul‌​ator.js
  • cokron
    cokron over 4 years
    too bad. Same thing here. In earlier versions of XCode, I had to change the version.startsWith to version.includes, which has been fixed. Now, a couple of lines further down, change 'YES' to true… A never ending story 😊
  • Max MacLeod
    Max MacLeod over 4 years
    Worked, thanks!. My guess is this problem occurs when attempting to run older React Native projects.
  • matt93
    matt93 over 4 years
    had to change it in the community package, worked, thanks
  • kojow7
    kojow7 over 4 years
    Radu Cimpian's answer tells you how to do SOLUTION #2.
  • Naman Jain
    Naman Jain over 4 years
    I cant find the runIOS directory. Any suggestions?
  • Oliver D
    Oliver D about 4 years
    @MixMasterMike i run your command but in every time just iPhone x launch :(
  • sdkcy
    sdkcy about 4 years
    @MixMasterMike you can run any installed simulator with that command react-native run-ios --simulator="iPhone SE". For example that command will run iPhone SE simulator, which is installed on Xcode.
  • Mix Master Mike
    Mix Master Mike about 4 years
    @OliverD unfortunately, I haven't touched my RN project since posting my comment. But did you happen to copy and paste the 2nd code? The one with the small capital R.
  • Mix Master Mike
    Mix Master Mike about 4 years
    @sdkcy yup, that's the idea. the key is to know the exact model you're trying to target as stated here.
  • Manoj Sehrawat
    Manoj Sehrawat about 4 years
    After trying everything I changes the version from 0.59.5 to 0.59.10 and it resolved the issue, great great advice :)
  • Grzegorz Pawlik
    Grzegorz Pawlik over 3 years
    Run react-native run-ios with --verbose flag. It will indicate the file where the logic above is located.
  • General Grievance
    General Grievance over 3 years
    Worked in this answer too: stackoverflow.com/a/55411403/4294399
  • Shn
    Shn almost 3 years
    Is there a way to do this with yarn?