-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Updating the react-native run-ios
command to use UDID
#6043
Conversation
By analyzing the blame information on this pull request, we identified @frantic to be a potential reviewer. |
@icodethings updated the pull request. |
Why remove the test ( |
@mkonicek I've also removed the |
The command that gets the simulator list now returns JSON. We don't need to use regex (inside |
Sorry for the lack of clarity. I meant adding a test for the new parsing code. |
@icodethings updated the pull request. |
I've moved the code that picks the simulator to a separate file and added tests for the function. |
}; | ||
} | ||
|
||
if(simulatorName === null && !match){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space after if
(everywhere, for consistency with the rest of this file and the codebase)
Cool, thanks for adding the tests. Good idea with using the |
@icodethings updated the pull request. |
@mkonicek I've fixed those things up |
There still seem to be quite a few styling issues here - would be so cool to get that shipped soon since its' finally going to allow running on iPhone 6s (currently there's naming collision) |
Is there a link to a code style guide?? |
Tests are green on master now. I restarted the build to make sure this passes all tests: The style guide is very simple, assumed |
describe('findMatchingSimulator', () => { | ||
it('should find simulator', () => { | ||
expect(findMatchingSimulator({ | ||
"devices": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move this JSON to a const? This way the test cases will be much more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frantic Each one of these JSON blobs are unique to each test. I was thinking it'd be easier to read if each of them were inside the test. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I find it very hard to read this test file. I believe it will make it easier if you use same inputs for each test – currently the search token ('iPhone 6') and expected result are deeply burrowed inside the test function, and the IDs are very random.
@icodethings updated the pull request. |
1 similar comment
@icodethings updated the pull request. |
@mkonicek There was one thing around moving the JSON blobs in the test to the top of the document that you can see in the changed files. Other than that, I've just done a rebase and pushed so we should see test come green soon! |
version | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can you kill all the empty lines inside this method?
cc @frantic For final review. Looks good to me in general, also has a test now. |
Updating the `react-native run-ios` command to launch the simulator based off the UUID and to retrieve the list of simulators with the --json flag and therefor removing the reliance on regex parsing and the `local-cli/runIOS/parseIOSSimulatorsList.js`. This solves a few problems: 1) When trying to launch an iOS simulator with just the name when you have other simulators that are similarly named. For example, you may have a simulator called 'iPhone 6' and one called iPhone 6 + 38mm Apple Watch'. If you try and run `xcrun instruments -w "iPhone 6"` you will get an error Instruments Usage Error : Ambiguous device name/identifier 'iPhone 6'. 2) If there is a simulator with brackets in it's name (e.g. "iPhone 6 (test 2)") the regex will parse the contents of the contents of the brackets as the UDID. This isn't an issue prior to this change for launching the simulator, but the UDID is used for building the project so it would have failed there. 3) It won't launch unavailable simulators. Because we can accurately get the status of each simulator, we can filter out ones that are not in the available state. This could be extended to check if they are already booted, or to use the default one as the booted one. All in all, this feels like a must more robust way of parsing the output of the list of simulators. I've also removed the default of 'iPhone 6' for the currently booted simulator, or the first in the list. If there is a simulator that is booted, we can't boot any others.
@icodethings updated the pull request. |
1 similar comment
@icodethings updated the pull request. |
return null; | ||
} | ||
const devices = simulators.devices; | ||
var match; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use let
for consistency?
* @param Object simulators a parsed list from `xcrun simctl list --json devices` command | ||
* @param String|null simulatorName the string with the name of desired simulator. If null, it will use the currently | ||
* booted simulator, or if none are booted, the first in the list. | ||
* @returns {Object} {udid, name, version} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer using @flow
, doctype comment types are not typechecked
@icodethings do you have any updates for this pull request? It's been a while so we wanted to check in and see if you've looked at the requested changes. |
@icodethings Just checking if you have time to update this PR. It would be great to ship this! |
@icodethings @jsierles any way we can get some traction on this so we can merge it in? |
It looks like the last comments are mostly nits and a comment about the readability of the test. I'll merge this because quite a few people need the feature. @facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review internal test results. |
Looks like this has now merge conflicts and needs to be rebased, sorry! @icodethings, @mbraude, @jsierles, @grabbou would you be up for sending a new PR which is just this PR rebased, and using Flow instead of types in JS docs as frantic suggested? I'll close this PR just so it doesn't stay open indefinitely (there have been no updates from author in a while). A new PR is definitely welcome, this fixes a bug many people will run into! |
Updating the
react-native run-ios
command to launch the simulator based off the UUID and to retrieve the list of simulators with the --json flag and therefore removing the reliance on regex parsing and thelocal-cli/runIOS/parseIOSSimulatorsList.js
.This solves a few problems:
For example, you may have a simulator called 'iPhone 6' and one called 'iPhone 6 + 38mm Apple Watch'.
If you try and run
xcrun instruments -w "iPhone 6"
you will get an errorInstruments Usage Error : Ambiguous device name/identifier 'iPhone 6'
.This isn't an issue prior to this change for launching the simulator, if that was the only simulator starting with 'iPhone6' as the
(test 2)
would be stripped from the name. The UDID is used for building the project so it would have failed there too.This could be extended to check if they are already booted, or to use the default one as the booted one.
All in all, this feels like a must more robust way of parsing the output of the list of simulators.
Tests
I have tested this with the following setup of simulators:
This would previously not work because running
xcrun instruments -w "iPhone 6"
would match all of the above that start with "iPhone 6" and throw an error.