Created
November 30, 2023 13:05
-
-
Save DavidBrunow/3ef4a1fa3e61c09411270c7c181c3174 to your computer and use it in GitHub Desktop.
ci_pre_xcodebuild.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [[ $CI_XCODEBUILD_ACTION == "test-without-building" ]] | |
then | |
# Setup the simulators so that they only have one preferred language. | |
# This works around an issue where the simulators on Sonoma have multiple | |
# preferred languages which include Arabic and therefore provide different | |
# results when running snapshot tests. | |
# | |
# This solution was inspired by: https://stackoverflow.com/a/74335552 | |
brew install jq | |
brew install parallel | |
# In my testing running more than 2 jobs in parallel led to flaky tests | |
# where the simulators would error out. | |
xcrun simctl list -j "devices" \ | |
| jq -r '.devices | with_entries(select(.key | contains("iOS"))) | map(.[] | select(.isAvailable == true)) | .[] .udid' \ | |
| parallel --jobs 2 'echo {}; xcrun simctl boot {}; xcrun simctl spawn {} defaults write "Apple Global Domain" AppleLanguages -array en; xcrun simctl spawn {} defaults write "Apple Global Domain" AppleLocale -string en_US; xcrun simctl shutdown {};' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment