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/bash | |
# Enables full/split-screen window modes in the running Simulator.app instance | |
# (original idea: https://twitter.com/stroughtonsmith/status/799664540996739073) | |
# | |
# Works by attaching with LLDB to the running Simulator.app instance and | |
# adding -Primary, -Auxiliary and -AllowsTiling collectionBehavior's to existing windows. | |
# Note that this is usually impossible due to SIP (System Integrity Protection). One | |
# workaround is to remove code signature from the Simulator binary. | |
# | |
# 1. Make sure Simulator.app is running | |
# 2. Run this | |
# - Follow instructions to work around SIP (once for each Xcode update) | |
# 3. Notice 'Enter Full Screen' (the right one, green) button is now enabled on the Simulator window title bar | |
# 4. Long-press it to enter tiling mode | |
# - Note that the usual way of setting up splits through Mission Control won't work for this window | |
path=${1:-"/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator"} | |
[ -f $path ] || { | |
>&2 echo "Invalid simulator path: $path" | |
exit 1 | |
} | |
codesign --display "$path" 2>/dev/null && { | |
>&2 cat <<-EOF | |
Simulator binary is code-signed. LLDB won't be able to attach due to System Integrity Protection. | |
Close Simulator and remove code signature with: | |
codesign --remove-signature "$path" | |
EOF | |
exit 2 | |
} | |
lldb \ | |
--attach-name Simulator \ | |
--batch \ | |
--one-line "expr ((NSWindow *)[(NSArray *)[[NSApplication sharedApplication] windows] setValue:@(1<<7|1<<8|1<<11) forKey:@\"collectionBehavior\"]);" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment