Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent booting already booted simulators #2033

Conversation

szymonrybczak
Copy link
Collaborator

Summary:

Fixes: #2032

The if statement was checking booted value, but in some code path, the booted value didn't exist. I unified this, to use state field.

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Boot iOS simulator
  3. Run this command:
node /path/to/react-native-cli/packages/cli/build/bin.js run-ios

You should see booted simulator, and this simulator shouldn't boot another time.

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@szymonrybczak szymonrybczak force-pushed the fix/prevent-booting-already-booted-simulators branch from de7eeee to 0e1c755 Compare July 25, 2023 11:13
@badbeoti
Copy link
Contributor

@szymonrybczak
Hi it's just simple question.
Ever since I updated RN (0.71). Always run my physical device by default when I connect my iPhone from Mac.
I'm not using ios-deploy so in my case it is not useful things.
But it is normal(when run-ios run physical device by default) right?

@szymonrybczak
Copy link
Collaborator Author

@badbeoti Hey, so by default since React Native 0.71, we get booted simulators (and devices), and we launch app on them, so even if user doesn't have installed ios-deploy it will try install app on physical device, I think this a bug, because app won't be installed correctly on physical device without ios-deploy - this should be fixed, we need to check before launching on physical device if ios-deploy is installed`. Anyway this is not perfect place for discussing this. Please create issue with that, or if you're able create fix for this :D Thanks for spotting!

@szymonrybczak
Copy link
Collaborator Author

@badbeoti I checked this right and we're checking if ios-deploy is installed before running app on physical devices (if it isn't installed we show error) - so I think there's no need for improvements here. If you have any other thoughts how this should be solved - please create separate issue for this, because this is not perfect place for discussing this.

@badbeoti
Copy link
Contributor

@szymonrybczak
Yeah I think same too(no need other things).
Thx!

@thymikee
Copy link
Member

thymikee commented Aug 9, 2023

@okwasniewski would you mind looking at this and whether we're not cutting out support for older (but still supported) Xcode versions?

@okwasniewski
Copy link
Contributor

@okwasniewski would you mind looking at this and whether we're not cutting out support for older (but still supported) Xcode versions?

@thymikee Unfortunately, I'm not sure about the support for the older Xcode versions. However, I have the same logic for checking booted simulators in MiniSim so this shouldn't be an issue.

@liamjones
Copy link
Contributor

I think I can help with that question @thymikee.

Xcode 14.2 is the earliest version supported by Apple if you want to upload binaries to the App Store: https://developer.apple.com/news/?id=jd9wcyov So I'm assuming that's as far back as you need to support?

I've just tried the xcrun simctl command that getSimulators runs and it looks like it uses "state": "Booted" etc still in that version:

~ via  v18.17.1
❯ xcode-select -p
/Applications/Xcode14.2.app/Contents/Developer

~ via  v18.17.1
❯ xcrun simctl list --json devices
{
  "devices" : {
    "com.apple.CoreSimulator.SimRuntime.watchOS-9-4" : [
      {
        "lastBootedAt" : "2023-08-11T08:24:48Z",
        "dataPath" : "\/Users\/liam.jones\/Library\/Developer\/CoreSimulator\/Devices\/58DDD451-8F10-4869-AB6C-878A9C441530\/data",
        "dataPathSize" : 130007040,
        "logPath" : "\/Users\/liam.jones\/Library\/Logs\/CoreSimulator\/58DDD451-8F10-4869-AB6C-878A9C441530",
        "udid" : "58DDD451-8F10-4869-AB6C-878A9C441530",
        "isAvailable" : true,
        "logPathSize" : 20480,
        "deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-40mm",
        "state" : "Shutdown",
        "name" : "Apple Watch Series 5 (40mm)"
      }
    ],
    "com.apple.CoreSimulator.SimRuntime.iOS-16-4" : [
      {
        "lastBootedAt" : "2023-07-25T15:55:17Z",
        "dataPath" : "\/Users\/liam.jones\/Library\/Developer\/CoreSimulator\/Devices\/F345B3A6-1B93-4C69-97E2-9D33F5114921\/data",
        "dataPathSize" : 81960960,
        "logPath" : "\/Users\/liam.jones\/Library\/Logs\/CoreSimulator\/F345B3A6-1B93-4C69-97E2-9D33F5114921",
        "udid" : "F345B3A6-1B93-4C69-97E2-9D33F5114921",
        "isAvailable" : false,
        "availabilityError" : "runtime profile not found using \"System\" match policy",
        "logPathSize" : 20480,
        "deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation",
        "state" : "Shutdown",
        "name" : "iPhone SE (3rd generation)"
      }
    ],
    "com.apple.CoreSimulator.SimRuntime.iOS-16-2" : [
      {
        "lastBootedAt" : "2023-08-11T08:25:12Z",
        "dataPath" : "\/Users\/liam.jones\/Library\/Developer\/CoreSimulator\/Devices\/7386593E-A5AF-44AB-AAC6-01B8475AB2AE\/data",
        "dataPathSize" : 315113472,
        "logPath" : "\/Users\/liam.jones\/Library\/Logs\/CoreSimulator\/7386593E-A5AF-44AB-AAC6-01B8475AB2AE",
        "udid" : "7386593E-A5AF-44AB-AAC6-01B8475AB2AE",
        "isAvailable" : true,
        "logPathSize" : 40960,
        "deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-8",
        "state" : "Booted",
        "name" : "iPhone 8"
      }
    ]
  }
}

@thymikee thymikee merged commit f8db7b2 into react-native-community:main Aug 11, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

run-ios trying to boot already booted devices
5 participants