Last active
November 22, 2020 18:13
-
-
Save username0x0a/a1b1efc3aaa7660686a6edfd0b520a4c to your computer and use it in GitHub Desktop.
iOS Simulator frame normalizing script – helps keeping your Xcode 9.1+ Simulator windows in sane and effective sizes!
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
tell application "Simulator" to activate -- needs to be in front | |
tell application "System Events" to tell application process "Simulator" | |
try | |
repeat with wnd in windows | |
set t to name of wnd | |
set tbh to 22 -- toolbar height | |
if t contains "iPhone X" then | |
set size of wnd to {375, 812 + tbh} | |
else if t contains "iPhone" and t contains "Plus" then | |
set size of wnd to {414, 736 + tbh} | |
else if t contains "iPhone 8" or t contains "iPhone 7" or t contains "iPhone 6" then | |
set size of wnd to {375, 667 + tbh} | |
else | |
set size of wnd to {320, 568 + tbh} | |
end if | |
end repeat | |
on error errmess | |
log errmess | |
end try | |
end tell |
After a very nutritious debate over an issue on Apple Bug Tracker, some change is coming. Simulator app in Xcode 10 newly introduces a “Point accurate” option to scale the Simulator window thus making this script not needed anymore. Hooray!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As Apple has dropped the useful 50% / 100% / 200% zooming scales from the Simulator app, setting the proper or useful working frame is impossible especially on non-Retina monitors. This script tries to help with this struggle – predefined sizes are available for iPhone SE and iPhone 8. Fell free to extend this according to your needs.
By using Automator, you can even create an application bundle so you can easily reach this feature using Spotlight. All you need to do is basically creating an app in Automator, export it and allow the app in Accessibility access section in your System Preferences → Security & Privacy.
Pull requests are welcome. Please refer this gist if you publish this code elsewhere.