[CI] Dynamically pick latest simulator device#15993
[CI] Dynamically pick latest simulator device#15993andrewheard wants to merge 6 commits intomainfrom
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
…nto ah/dynamic-simulator-selection
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic simulator selection in scripts/build.sh and adds a new utility script, scripts/install_simulators.sh, to manage simulator runtime installations. The review feedback highlights the need for explicit error handling when using command substitutions and suggests a more robust jq query to handle potential null values when fetching simulator names.
| if [[ "$xcode_major" -gt 16 ]]; then | ||
| iphone_simulator_name="iPhone 17" | ||
| fi | ||
| iphone_simulator_name=$(get_latest_simulator "iOS" "iPhone") |
There was a problem hiding this comment.
When get_latest_simulator fails, it returns a non-zero exit code, but the script doesn't exit because of how set -e handles command substitutions. This can lead to iphone_simulator_name being empty and causing issues later. To ensure the script fails immediately on error, you should explicitly check the exit code.
| iphone_simulator_name=$(get_latest_simulator "iOS" "iPhone") | |
| iphone_simulator_name=$(get_latest_simulator "iOS" "iPhone") || exit 1 |
| -destination "platform=iOS Simulator,name=${iphone_simulator_name}" | ||
| -destination "platform=iOS Simulator,OS=latest,name=${iphone_simulator_name}" | ||
| ) | ||
| watchos_simulator_name=$(get_latest_simulator "watchOS" "Apple Watch") |
There was a problem hiding this comment.
When get_latest_simulator fails, it returns a non-zero exit code, but the script doesn't exit because of how set -e handles command substitutions. This can lead to watchos_simulator_name being empty and causing issues later. To ensure the script fails immediately on error, you should explicitly check the exit code.
| watchos_simulator_name=$(get_latest_simulator "watchOS" "Apple Watch") | |
| watchos_simulator_name=$(get_latest_simulator "watchOS" "Apple Watch") || exit 1 |
| macos_flags=( | ||
| -destination 'platform=OS X,arch=x86_64' | ||
| ) | ||
| tvos_simulator_name=$(get_latest_simulator "tvOS" "Apple TV") |
There was a problem hiding this comment.
When get_latest_simulator fails, it returns a non-zero exit code, but the script doesn't exit because of how set -e handles command substitutions. This can lead to tvos_simulator_name being empty and causing issues later. To ensure the script fails immediately on error, you should explicitly check the exit code.
| tvos_simulator_name=$(get_latest_simulator "tvOS" "Apple TV") | |
| tvos_simulator_name=$(get_latest_simulator "tvOS" "Apple TV") || exit 1 |
| first | | ||
| .name |
There was a problem hiding this comment.
If map(select(.name | contains($dev))) returns an empty array, first will evaluate to null. Attempting to access .name on null will cause jq to error. Using the optional operator ? (.name?) will prevent this error by gracefully returning null instead, making the query more robust.
| first | | |
| .name | |
| first | .name? |
Updated
build.shto dynamically select an available simulator for the latest version of the specified OS. For example,get_latest_simulator "iOS" "iPhone"returnsiPhone 17 Pro. This may reduce CI failures due to missing devices, requiring fixes like #15992.Added an
install_simulators.shscript that skips downloading when a platform is available already.xcodebuild -downloadPlatformwas downloading iOS 26.3.1 runtimes when iOS 26.2 or iOS 26.3 was already available. This added minutes to the CI runs and gigabytes upon gigabytes of bandwidth usage.#no-changelog