Skip to content

Fix simulator runtime OS version mapping for mismatched version strings - #29737

Open
owurman wants to merge 8 commits into
fastlane:masterfrom
Acid-Remap:fix/simulator_runtime_os_version
Open

Fix simulator runtime OS version mapping for mismatched version strings#29737
owurman wants to merge 8 commits into
fastlane:masterfrom
Acid-Remap:fix/simulator_runtime_os_version

Conversation

@owurman

@owurman owurman commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Motivation and Context

Fixes an issue where simulator runtime versions reported by xcrun simctl list devices section 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 by xcrun simctl list -j runtimes) is "26.0.1". This mismatch causes fastlane to incorrectly identify simulator OS versions, which causes snapshot to fail.

  • Modified DeviceManager.simulators to query xcrun simctl list -j runtimes for accurate runtime version mapping
  • Added runtime_name_to_version method that creates a mapping from runtime names (e.g., "iOS 26.0") to actual versions (e.g., "26.0.1")
  • Updated device creation to use the actual runtime version instead of the section header version

Testing Steps

  • Added new test fixtures:
    • DeviceManagerSimctlOutputWithVersionMismatch - simulated device list output with version mismatch
    • XcrunSimctlListRuntimesOutputWithVersionMismatch - JSON runtime output showing actual versions
  • Added test case properly maps runtime names to actual versions for version mismatch fix that validates the mapping as a unit test
  • Added test case fixes iOS version mismatch by using actual runtime versions instead of section header versions that verifies devices get the correct OS version (26.0.1) instead of the section header version (26.0)
  • Existing tests continue to pass
  • My snapshot failure no longer fails (end-to-end verification)

🤖 Generated with Claude Code

@markusfassbender-lb markusfassbender-lb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix! Thank you

@piro49

piro49 commented Nov 7, 2025

Copy link
Copy Markdown

Looking forward for this fix!

@owurman

owurman commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

All I need is an approval by a reviewer with write access ;-)

@iBotPeaches

Copy link
Copy Markdown
Member

Taking a look. Mind rebasing so we can have a recent pipeline to see if green/red?

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

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.
@owurman
owurman force-pushed the fix/simulator_runtime_os_version branch from ff9f709 to 8779ef2 Compare November 20, 2025 17:27
@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

That fail looks potentially legit. I'm investigating.

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

The Ubuntu tests need a mock for xcrun with capture2. Working on it.

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

@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?

@iBotPeaches

Copy link
Copy Markdown
Member

@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.

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

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.

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

@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).

@iBotPeaches

Copy link
Copy Markdown
Member

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.

thanks for this catch. Restored bundler 2.4 - 9338753

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

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.

@iBotPeaches

Copy link
Copy Markdown
Member

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+

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

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.

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

@iBotPeaches Looks good to go! I don't seem able to request reviewers, but please do.

@iBotPeaches

Copy link
Copy Markdown
Member

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.

@owurman

owurman commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

I pinged the reporters in #29481 to take a look, @piro49 does this fix it for you?

@owurman

owurman commented Nov 25, 2025

Copy link
Copy Markdown
Contributor Author

@iBotPeaches I don't know if we're going to get any other reviewers on this, unfortunately...

@piro49

piro49 commented Nov 26, 2025

Copy link
Copy Markdown

@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:

[17:28:20]: Ignoring 'iPhone 17 Pro', couldn't find matching simulator
[17:28:20]: Couldn't find any matching simulators for '["iPhone 17 Pro"]' - falling back to default simulator
[17:28:20]: Found simulator "iPhone 16 Pro (18.4)"

@owurman

owurman commented Nov 26, 2025

Copy link
Copy Markdown
Contributor Author

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:

devices([
"iPhone 17 Pro"
])
ios_version("26.0.1")

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?

@piro49

piro49 commented Nov 27, 2025

Copy link
Copy Markdown

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.
I’m running the run_tests lane with a specific simulator defined, as mentioned above. Previously, this wasn’t an issue. Specifying a simulator without an OS version used to work fine. Fastlane would simply select the latest OS available for that simulator.

@owurman

owurman commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

@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 ios_version. I would suggest that perhaps this can get merged, and if it breaks others' implementations, we can back it out and investigate further. But without other users chiming in, we have only my own workflow to judge against.

@iBotPeaches

Copy link
Copy Markdown
Member

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

snapshot unnecessarily falls back to iOS 18.3

4 participants