device_ids=("C741F3CD-FDAC-49EA-A4DB-7F797B97291E" "428183B6-3EB8-4D36-9938-9D07C141BF49")
# The value to use is now just 'dark' or 'light'
appearance=dark
for device in "${device_ids[@]}"; do
xcrun simctl boot $device
xcrun simctl ui $device appearance $appearance
done
device_ids=("C741F3CD-FDAC-49EA-A4DB-7F797B97291E" "428183B6-3EB8-4D36-9938-9D07C141BF49")
# Determine the plist value for the desired style: "dark" -> 2 / "light" -> 1
style=2
for device_id in "${device_ids[@]}"; do
plist_path="${HOME}/Library/Developer/CoreSimulator/Devices/${device_id}/data/Library/Preferences/com.apple.uikitservices.userInterfaceStyleMode.plist"
printf '\n%s' "Set style $style for device $device_id ($plist_path)"
killall "Simulator"
xcrun simctl shutdown booted
xcrun simctl erase $device_id
# Crate the plist since it might not be available after erase
[[ ! -f "$plist_path" ]] && /usr/libexec/PlistBuddy -c "save" $plist_path
# Set the style mode
plutil -replace UserInterfaceStyleMode -integer $style $plist_path
done