-
-
Notifications
You must be signed in to change notification settings - Fork 417
Prefer currently booted iOS Simulator #1938
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
base: develop
Are you sure you want to change the base?
Conversation
Updated XCodeHelper.getSimulatorID to check for a currently booted simulator via `xcrun simctl list devices booted` before falling back to project target flags or default logic. This improves behavior when switching simulators manually in the Simulator app.
getBootedSimulator now uses the same logic to match simulator name as elsewhere and also returns SimulatorInfo. getSimulatorName now returns the booted simulator name.
It appears that modern simulators have started adding their CPU types to their names, "like iPad Air (M4)" which was causing the exiting code to return the incorrect string for the ID (it would return 'M4' as the ID in that case). I fixed this by searching for ID's which are specifically 36 chars long which is the format the ID's follow. I think this probably would have affected the code in the current release version of lime?
|
I have updated the code to be consistent with the existing code as requested. I then encountered a strange issue where it wasn't working on certain simulators - those which had the cpu type in their names - such as "iPad air (M2)" - the (M2) part was breaking the extractSimulatorID function because of the parenthesis. I changed extractSimulatorID so that it looks for a 36 digit ID (all simulator IDs are). This is probably affecting the current lime release, though obviously only simulators which have the CPU type in their names. |
|
Thanks! I'll test a bit and get it merged when I have a chance. |
|
|
||
| var potentialID = line.substring(openParen + 1, closeParen); | ||
|
|
||
| // Simulator IDs are always UUID strings exactly 36 chars long |
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.
If it really is that simple, we can save a lot of space here.
private static function extractSimulatorID(line:String):String
{
// Simulator IDs are always UUID strings exactly 36 chars long, in parentheses
var id:EReg = ~/\(([A-F0-9\-]{36})\)/;
return id.match(line) ? id.matched(1) : "";
}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.
Yeah that's much shorter for sure.
| return simulator; | ||
| } | ||
| return simulator.name; | ||
| return null; |
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.
if (simulator != null) return simulator else return null can be simplified to return simulator.
This PR updates XCodeHelper.getSimulatorID to first check if a simulator is already running and use that device's UDID, if there are no simulators running it will fall back to original behaviour.
This improves usability when switching simulators manually via the Simulator app, as users may wish to switch simulators multiple times during testing. For example if I open an "iPad 11 inch" simulator specifically and then build I'd expect it to be installed and run on that simulator.
This change is non-breaking and falls back to the existing logic if no simulator is currently running.