Fix simulator runtime OS version mapping for mismatched version strings - #29737
Fix simulator runtime OS version mapping for mismatched version strings#29737owurman wants to merge 8 commits into
Conversation
|
Looking forward for this fix! |
|
All I need is an approval by a reviewer with write access ;-) |
|
Taking a look. Mind rebasing so we can have a recent pipeline to see if green/red? |
|
Can do! Stand by... |
There is a bug where fastlane was using the inferred OS from the runtime name which wasn't always right. For example, OS 26.0.1 runtime was name "iOS 26.0". This was causing xcodebuild to use the wrong devices. This commit maps to the actual version number, falling back on the inferred one.
ff9f709 to
8779ef2
Compare
|
That fail looks potentially legit. I'm investigating. |
|
The Ubuntu tests need a mock for xcrun with capture2. Working on it. |
|
@iBotPeaches I'm getting bundler issues locally because it seems the latest Gemfile was created with bundler 2.5.23 and requires Ruby 3, and I'm still on 2.7.8. Before I go through the process, can you please confirm that fastlane now requires ruby 3 and I'm not misinterpretting the issue? |
Hmm guess I did on that CI fix bump to Bundler 2.5 (which is min 3.0). While I do have a goal to officially drop Ruby 2.x - that was not my intent on that PR. I'll see if I can quickly fix that (#29762), but to be blunt that is like 3 years old in terms of versions. It was getting extremely difficult to have a pipeline to work on Ruby 2.6 to Ruby 3.4. |
|
It's fine, I'm not judging. I agree it's probably time to drop Ruby 2, I just wanted to make sure we were on the same page before I did that. |
|
@iBotPeaches FWIW, the tests for this stuff are a bit of a mess. They are mocking stuff that gets cached and leaks into other tests. I'm trying to clean that up too, rather than leave it alone (even though that would be easier). |
thanks for this catch. Restored bundler 2.4 - 9338753 |
|
So there's a potential real issue here. My code assumed what appears to be Xcode 26 behavior, which is that dot-releases of SDKs do not co-exist. That is, downloading iOS 26.0.1 simulator removed iOS 26.0. That was likely not the case in the past, and one of the tests catches this situation where we (hypothetically, anyway) have both 17.0 and 17.0.1 simulators downloaded. The fact of the matter is that this code changes behavior, and could negatively affect someone still on an old version of Xcode or who otherwise has somehow downloaded coexisting dot releases of the simulators. I'm trying to think of a solution which would maintain backwards compatibility. |
There are some helpful helpers for like xcode_version, etc. If you need to invoke different logic on Xcode 26+ |
… one runtime available per iOS (e.g. 17.0 and 17.0.1 both can exist)
|
I ended up changing my approach to not assume it was one os version per platform, and add all available simulators in that case. I think it will fix the original bug while maintaining backwards compatibility. I tested locally (I think: it's honestly hard to tell if I'm doing it right) and my original version-during-snapshot bug is still fixed, but the scan tests are passing now, too. Let's see what CI does. |
|
@iBotPeaches Looks good to go! I don't seem able to request reviewers, but please do. |
|
cool! If anyone chimes in and it works for them, that helps me a lot. Don't do too much simulator stuff to confidently have a strong understanding of day to day usage. |
|
@iBotPeaches I don't know if we're going to get any other reviewers on this, unfortunately... |
|
@owurman @iBotPeaches Sorry for the late response! I did run this PR testwise with Xcode 26.0.1 and simulator defined as "iPhone 17 Pro" instead of "iPhone 17 Pro (26.0)" and got this message again: |
|
I'm not sure where default simulator comes from. When I ran snapshot with a simulator name that's missing, it just fails. Either way, this change was about allowing you to specify iOS 26.0.1 instead of 26.0. For example, in Snapfile: But you'd still need an iPhone 17 Pro simulator. Is yours perhaps literally named "iPhone 17 Pro (26.0)" with the iOS version in the name? |
|
Yes, that’s probably the case. I assume Fastlane uses whichever simulator it finds first. We have multiple versions of Xcode installed on our CI, along with the simulators that come with each version. |
|
@iBotPeaches I'm not sure what else to do here. There are tests to validate behavior that are passing. @piro49 seems to have a slightly different issue, but it's not related to selecting the right simulator from |
|
Yeah tough for me as I don't have full confidence in any change as not a user of this. I merged a change yesterday I felt a bit safer with which might help here - #29894 |
Checklist
bundle exec rspecfrom the root directory to see all new and existing tests passbundle exec rubocop -ato ensure the code style is validci/circlecibuilds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)Motivation and Context
Fixes an issue where simulator runtime versions reported by
xcrun simctl list devicessection headers don't match the actual runtime versions, causing incorrect OS version detection.This also likely fixes #29481 which seems similar if not identical to the issue I was having.
Description
When running
xcrun simctl list devices, the section headers may show versions like "iOS 26.0", but the actual runtime version (as reported byxcrun simctl list -j runtimes) is "26.0.1". This mismatch causes fastlane to incorrectly identify simulator OS versions, which causes snapshot to fail.DeviceManager.simulatorsto queryxcrun simctl list -j runtimesfor accurate runtime version mappingruntime_name_to_versionmethod that creates a mapping from runtime names (e.g., "iOS 26.0") to actual versions (e.g., "26.0.1")Testing Steps
DeviceManagerSimctlOutputWithVersionMismatch- simulated device list output with version mismatchXcrunSimctlListRuntimesOutputWithVersionMismatch- JSON runtime output showing actual versionsproperly maps runtime names to actual versions for version mismatch fixthat validates the mapping as a unit testfixes iOS version mismatch by using actual runtime versions instead of section header versionsthat verifies devices get the correct OS version (26.0.1) instead of the section header version (26.0)🤖 Generated with Claude Code