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

[scan] Filter simulators with version greater than SDK version of active Xcode installation when choosing default #21677

Merged
merged 8 commits into from Dec 14, 2023

Conversation

wuaar1003
Copy link
Contributor

@wuaar1003 wuaar1003 commented Nov 29, 2023

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

Xcode 15 introduced a new Simulator subsystem in macOS that is shared across all Xcode versions installed on a machine. Previously, each Xcode had its own separate system service and set of devices for which it could run. With Xcode 15 installed, each Xcode now has access to many of the devices and runtimes for each Xcode version installed on a machine.

This is an issue for fastlane, as it currently picks the latest simulator version for a given device, unless the user explicitly specifies otherwise.

For example, suppose an environment has installations of both Xcode14 and Xcode15, with Xcode14 set as active. For the device 'iPhone 14', scan will select iOS simulator 17.0 instead of 16.4. One must use 'iPhone 14 (16.4)' to run on the default Xcode14 simulator.

Under the proposed changes, 'iPhone 14' would result in selection of the expected 16.4 simulator. If users wish to run on an older or newer simulator version, the behavior is as before i.e. 'iPhone14 (16.1)' for the older 16.1 simulator or 'iPhone 14 (17.0)' for the newer 17.0 simulator.

Description

The changes affect Scan::DetectValues. A function named detect_sdk_version is added to determine default simulator SDK versions of the active Xcode installation. We use this information as an upper bound when filtering the set of available simulators if users do not specify a version. The new filtering heuristic is contained within compatible_with_sdk.

Testing Steps

Updated unit tests to exercise new functionality. Tested in local envrionment and CI.

@wuaar1003 wuaar1003 changed the title [scan] Filter simulators with version greater than active Xcode installation when choosing default [scan] Filter simulators with version greater than SDK version of active Xcode installation when choosing default Nov 29, 2023
@wuaar1003 wuaar1003 marked this pull request as ready for review November 29, 2023 19:45
Copy link
Collaborator

@lacostej lacostej left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. A couple of comments.

Related to that feature, I see that we have lots of weird errors when setting up our simulators environments in CI and wonder if we could use some similar logic to avoid them (and speed up the setup) and thus the builds.

image

I believe this happens here

scan/spec/detect_values_spec.rb Outdated Show resolved Hide resolved
scan/lib/scan/detect_values.rb Outdated Show resolved Hide resolved
@wuaar1003
Copy link
Contributor Author

wuaar1003 commented Dec 1, 2023

@lacostej addressed the later two comments.

I see that we have lots of weird errors when setting up our simulators environments in CI and wonder if we could use some similar logic to avoid them

As far as I can tell, the logic would be different and would require more substantial changes to that file. For the error attached, what seems to be going on is xcrun simctl list devicetypes includes devices not supported by any installed runtime. On the other hand, xcrun simctl list runtimes --json includes a list of supportedDeviceTypes for each runtime.

fastlane_core/lib/fastlane_core/device_manager.rb Outdated Show resolved Hide resolved
scan/lib/scan/detect_values.rb Outdated Show resolved Hide resolved
scan/lib/scan/detect_values.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Logic looks good now, except maybe the place in the code where @runtime_build_os_version is populated depending on the caller calling things in order.

fastlane_core/lib/fastlane_core/device_manager.rb Outdated Show resolved Hide resolved
@milch milch merged commit 3d51313 into fastlane:master Dec 14, 2023
2 checks passed
@lacostej
Copy link
Collaborator

This change seems to have added the following message in output on some platforms.

nil versions are discouraged and will be deprecated in Rubygems 4

See https://app.circleci.com/pipelines/github/fastlane/fastlane/5943/workflows/b4bb5777-bafd-4817-bfc1-0087dc024778/jobs/94514

Probably caused by Gem::Version.new()

SubhrajyotiSen pushed a commit to KeepTruckin/fastlane that referenced this pull request Jan 17, 2024
…ive Xcode installation when choosing default (fastlane#21677)

* [scan] Filter simulators with version greater than currently installed SDK

* addressing feedback

* redo implementation using suggested CLI invocations

* better description for test case

* addressing feedback

* move runtime_build_os_versions into own function

* fix odd indentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants