0

xcode 12
react-native cli 4.13.1
cocoapods 1.10.1
react 0.63.4

I've encountered this problem more than once on my project, the first time I ended up rebuilding. I'm not sure what is causing it. When I "run-ios", the simulator is being chosen incorrectly, and attempts to run on a not present device.

:~/source/personal/<project>$; npx react-native run-ios --verbose 
debug Reading /Users/<user>/source/personal/<project>/ios/Podfile
debug Reading /Users/<user>/source/personal/<project>/ios/Podfile
debug Reading /Users/<user>/source/personal/<project>/ios/Podfile
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - @react-native-community/geolocation (to unlink run: "react-native unlink @react-native-community/geolocation")
  - @react-native-community/picker (to unlink run: "react-native unlink @react-native-community/picker")
  - react-native-maps (to unlink run: "react-native unlink react-native-maps")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
debug Reading /Users/<user>/source/personal/<project>/ios/Podfile.lock
info Found Xcode workspace "<project>.xcworkspace"
info Building (using "xcodebuild -workspace <project>.xcworkspace -configuration Debug -scheme <project> -destination id=FCBFA5B8-2A42-4B0F-AC8A-D43A1CC7C08E")
debug Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace <project>.xcworkspace -configuration Debug -scheme <project> -destination id=FCBFA5B8-2A42-4B0F-AC8A-D43A1CC7C08E


error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 70. To debug build logs further, consider building your app with Xcode.app, by opening <project>.xcworkspace.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace <project>.xcworkspace -configuration Debug -scheme <project> -destination id=FCBFA5B8-2A42-4B0F-AC8A-D43A1CC7C08E


xcodebuild: error: Unable to find a destination matching the provided destination specifier:
        { id:FCBFA5B8-2A42-4B0F-AC8A-D43A1CC7C08E }

    Available destinations for the "<project>" scheme:
        { platform:iOS Simulator, id:C671E44A-5901-4054-AABE-26394319C7D5, OS:14.4, name:iPad (8th generation) }
        { platform:iOS Simulator, id:FA9E687C-9E94-48E4-8592-BFFA51CFB107, OS:14.4, name:iPad Air (4th generation) }
        { platform:iOS Simulator, id:25FF1BD1-D6BF-481C-9B98-2F31417A1A1D, OS:14.4, name:iPad Pro (9.7-inch) }
        { platform:iOS Simulator, id:C9EBBEB7-D7C2-460E-AEF7-D0E41EF35051, OS:14.4, name:iPad Pro (11-inch) (2nd generation) }
        { platform:iOS Simulator, id:96529FA3-C77A-4969-8BB4-5FDF0C336630, OS:14.4, name:iPad Pro (12.9-inch) (4th generation) }
        { platform:iOS Simulator, id:EBEB0DE3-6D3E-4AAC-8EF5-AFE9659E72CB, OS:14.4, name:iPhone 8 }
        { platform:iOS Simulator, id:E252FD89-6E65-49DD-8A00-403626444DB5, OS:14.4, name:iPhone 8 Plus }
        { platform:iOS Simulator, id:41237E14-D8AF-4383-BC35-A7065F7F2A46, OS:14.4, name:iPhone 11 }
        { platform:iOS Simulator, id:23AA1BD3-0187-4522-99A8-75526721A2D2, OS:14.4, name:iPhone 11 Pro }
        { platform:iOS Simulator, id:EA72F6D7-B1DB-4EA9-9447-1D3FDFC2DA1A, OS:14.4, name:iPhone 11 Pro Max }
        { platform:iOS Simulator, id:CE1BFE8D-7326-4B38-A2C1-D91E43D05622, OS:14.4, name:iPhone 12 }
        { platform:iOS Simulator, id:1B59D058-57A5-4A8C-AA87-8FB531318C02, OS:14.4, name:iPhone 12 Pro }
        { platform:iOS Simulator, id:AE03D9A6-8D32-4F5F-AB34-AB91CD0E925B, OS:14.4, name:iPhone 12 Pro Max }
        { platform:iOS Simulator, id:9A59AE8D-695A-4882-9E32-5D053B1BCEA6, OS:14.4, name:iPhone 12 mini }
        { platform:iOS Simulator, id:8CBF1BCA-5731-4868-B726-38DC1EB527F1, OS:14.4, name:iPhone SE (2nd generation) }
        { platform:iOS Simulator, id:88114D51-5164-4C7F-BFA6-354FC6B4B22C, OS:14.4, name:iPod touch (7th generation) }

    Ineligible destinations for the "<project>" scheme:
        { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
        { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }

By digging into the scripts, I've found that the following code from <project>/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js chooses the simulator:

async function runOnSimulator(xcodeProject, scheme, args) {
  let simulators;

  try {
    simulators = JSON.parse(_child_process().default.execFileSync('xcrun', ['simctl', 'list', '--json', 'devices'], {
      encoding: 'utf8'
    }));
  } catch (error) {
    throw new (_cliTools().CLIError)('Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues.', error);
  }
  /**
   * If provided simulator does not exist, try simulators in following order
   * - iPhone X
   * - iPhone 8
   */


  const fallbackSimulators = ['iPhone X', 'iPhone 8'];
  const selectedSimulator = fallbackSimulators.reduce((simulator, fallback) => {
    return simulator || (0, _findMatchingSimulator.default)(simulators, {
      simulator: fallback
    });
  }, (0, _findMatchingSimulator.default)(simulators, args));

  if (!selectedSimulator) {
    throw new (_cliTools().CLIError)(`No simulator available with ${args.simulator ? `name "${args.simulator}"` : `udid "${args.udid}"`}`);
  }
...

but I am having a hard time understanding the code and figuring out why it's failing. Clearly, from here, I can hack in the target simulator I want to use, but I'd rather figure out where that's being cached and clear it out. Help?

righdforsa
  • 179
  • 1
  • 8

1 Answers1

0

To solve this issue, all I had to do was go to Xcode > Window > Devices and Simulators, and delete the offending simulator.

xcode_devices_and_simulators_menu

delete_device_menu

righdforsa
  • 179
  • 1
  • 8
  • I'm currently encountering an issue with a missing jsbundle. I don't think it has anything to do with deleting the simulator, but just in case, I'll put the fix here when I find it. – righdforsa Feb 14 '21 at 14:44
  • To fix the missing jsbundle issue, I had to update the file details in Xcode, as found here: https://stackoverflow.com/a/48097518/2070376 – righdforsa Feb 14 '21 at 15:27
  • Also FWIW, there are some interesting simulator directories in `/tmp` that might be relevant to the original issue, e.g. `/tmp/com.apple.CoreSimulator.SimDevice.` it's too late for me to find out. – righdforsa Feb 14 '21 at 15:28