Skip to content

Instantly share code, notes, and snippets.

@ZevEisenberg
Last active January 6, 2024 07:31
Show Gist options
  • Save ZevEisenberg/5167026 to your computer and use it in GitHub Desktop.
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
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