Last active
January 6, 2024 07:31
-
-
Save ZevEisenberg/5167026 to your computer and use it in GitHub Desktop.
Function to fix Xcode’s code snippets library by replacing it with the one from the ZevEisenberg/ios-convenience git repo
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
function fixXcode | |
{ | |
pushd > /dev/null | |
cd | |
xcodepath=`xcode-select --print-path`/.. | |
destination=$xcodepath/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets | |
shouldRelaunchXcode=false | |
if [[ `osascript -e 'tell app "System Events" to count processes whose name is "Xcode"'` == 1 ]]; then | |
shouldRelaunchXcode=true | |
fi | |
if [[ -e $destination ]]; then | |
osascript -e "tell application \"Xcode\" to quit" | |
git clone git://github.com/ZevEisenberg/ios-convenience.git > /dev/null 2>&1 | |
sudo cp ios-convenience/SystemCodeSnippets.codesnippets $destination | |
rm -rf ios-convenience | |
echo "Xcode is fixed." | |
else | |
echo "SystemCodeSnippets.codenippets does not exist or has moved. It should be at $destination" | |
fi | |
if $shouldRelaunchXcode; then | |
open $xcodepath/.. | |
fi | |
popd > /dev/null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment