It seems unavoidable for new Xcode versions to override any custom keybindings. Ditto for a custom, brighter text-cursor, which is pretty much a necessity when using a darker background. And let's not forget the plugins. Thus behold, a streamlined Xcode upgrade:
update_xcode {
# Change if not using default naming, "Xcode" and "Xcode-beta"
_update_xcode "Xcode"
[ -d "/Applications/Xcode-beta.app/" ] && _update_xcode "Xcode-beta"
}
_update_xcode {
XCODE_PATH="/Applications/$1.app"
PLUGINS_PATH="$HOME/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
SOURCE_PATH="$HOME/path/to/your/keybindings_etc"
# Update plugin UUIDs
uuid=$(defaults read $XCODE_PATH/Contents/Info DVTPlugInCompatibilityUUID)
find "$PLUGINS_PATH" -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add "$uuid"
# Restore keybindings
sudo cp -f $SOURCE_PATH/IDETextKeyBindingSet.plist $XCODE_PATH/Contents/Frameworks/IDEKit.framework/Versions/A/Resources
# Restore white text-cursor
sudo cp -f $SOURCE_PATH/DVTIbeamCursor.tiff $XCODE_PATH/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/
restart "$1"
}
restart {
osascript -e 'quit app "$1"'
open -a "$1"
}
Xcode 8 update
Apple hardened Xcode 8 against XcodeGhost and thus broke many plugins. If you value your plugins over safety, then you'll have to re-sign Xcode:
sudo codesign -f -s "Some certificate e.g. 'iPhone Developer: Your Name (AAAAAAAA)'" /Applications/Xcode.app
Not ideal, but until Xcode supports more than mere text-extensions, I think the tradeoff is worth it.