Skip to content

Instantly share code, notes, and snippets.

@erikkerber
Last active October 26, 2023 17:57
Show Gist options
  • Save erikkerber/630e00c1afebd3ef6881a60a22e2e15b to your computer and use it in GitHub Desktop.
Save erikkerber/630e00c1afebd3ef6881a60a22e2e15b to your computer and use it in GitHub Desktop.
Bug with simctl list devices --json with duplicate sim runtime identifiers
#!/bin/bash
set -x
xcrun simctl delete all
DEVELOPER_DIR=/Applications/Xcode-15.0.0.app/Contents/Developer xcrun simctl create "Made with Xcode 15" "iPhone 15 Pro" "com.apple.CoreSimulator.SimRuntime.iOS-17-0"
set +x; echo -e "\n\n+++++++++++++++++++++ Device shows up with Xcode 15.0.0 +++++++++++++++++++++++++++++++"; set -x
# Shows the newly created simulator
DEVELOPER_DIR=/Applications/Xcode-15.0.0.app/Contents/Developer xcrun simctl list devices
set +x; echo -e "\n\n+++++++++++++++++++++ Xcode 15.0.0 +++++++++++++++++++++++++++++++"; set -x
# The json output appears to "squash" the `com.apple.CoreSimulator.SimRuntime.iOS-17-0` key:
DEVELOPER_DIR=/Applications/Xcode-15.0.0.app/Contents/Developer xcrun simctl list devices -j
set +x; echo -e "\n\n+++++++++++++++++++++ Xcode 15.0.1 +++++++++++++++++++++++++++++++"; set -x
# If you use the newest Xcode, it appears to give the newer runtime precedent and will appear in the JSON output
DEVELOPER_DIR=/Applications/Xcode-15.0.1.app/Contents/Developer xcrun simctl list devices -j
@erikkerber
Copy link
Author

erikkerber commented Oct 26, 2023

Without disambiguation between the 17.0.0 and 17.0.1 runtimes (both share a runtime ID of com.apple.CoreSimulator.SimRuntime.iOS-17-0), both simctl create and the --json output when listing devices show bugs or inconsistencies.

 bash bug.sh
+ xcrun simctl delete all
+ DEVELOPER_DIR=/Applications/Xcode-15.0.0.app/Contents/Developer
+ xcrun simctl create 'Made with Xcode 15' 'iPhone 15 Pro' com.apple.CoreSimulator.SimRuntime.iOS-17-0
70DD0227-1F8A-49C3-84BE-1019C3E07600
+ set +x


+++++++++++++++++++++ Device shows up with Xcode 15.0.0 +++++++++++++++++++++++++++++++
+ DEVELOPER_DIR=/Applications/Xcode-15.0.0.app/Contents/Developer
+ xcrun simctl list devices
== Devices ==
-- iOS 17.0 --
    Made with Xcode 15 (70DD0227-1F8A-49C3-84BE-1019C3E07600) (Shutdown)
-- iOS 17.0 --
+ set +x


+++++++++++++++++++++ Xcode 15.0.0 +++++++++++++++++++++++++++++++
+ DEVELOPER_DIR=/Applications/Xcode-15.0.0.app/Contents/Developer
+ xcrun simctl list devices -j
{
  "devices" : {
    "com.apple.CoreSimulator.SimRuntime.iOS-17-0" : [

    ]
  }
}
+ set +x


+++++++++++++++++++++ Xcode 15.0.1 +++++++++++++++++++++++++++++++
+ DEVELOPER_DIR=/Applications/Xcode-15.0.1.app/Contents/Developer
+ xcrun simctl list devices -j
{
  "devices" : {
    "com.apple.CoreSimulator.SimRuntime.iOS-17-0" : [
      {
        "dataPath" : "\/Users\/ekerber\/Library\/Developer\/CoreSimulator\/Devices\/70DD0227-1F8A-49C3-84BE-1019C3E07600\/data",
        "dataPathSize" : 18337792,
        "logPath" : "\/Users\/ekerber\/Library\/Logs\/CoreSimulator\/70DD0227-1F8A-49C3-84BE-1019C3E07600",
        "udid" : "70DD0227-1F8A-49C3-84BE-1019C3E07600",
        "isAvailable" : true,
        "deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro",
        "state" : "Shutdown",
        "name" : "Made with Xcode 15"
      }
    ]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment