Skip to content

Instantly share code, notes, and snippets.

@polqf
Last active August 26, 2021 16:42
Show Gist options
  • Save polqf/d294e0bc55a23ad1c39c to your computer and use it in GitHub Desktop.
Save polqf/d294e0bc55a23ad1c39c to your computer and use it in GitHub Desktop.
SourceKit Fix
#
# This fix should solve most of the problems with SourceKit (Not only with Swift, also with Obj-C). Such as:
# - Not having autocompletion
# - False errors
#
# This is just a temporal fix. The problem could eventually return.
# If that happens, just re-run this file
#
# The implementation comes from an answer in stackoverflow, which helped me a lot.
#
# Source: http://stackoverflow.com/questions/27083848/xcode-source-kit-will-not-stop-crashing-with-swift
#
# Pol Quintana. 2015
# @poolqf
#
xcodeV = ARGV[0] || "Xcode"
puts "πŸ’» Closing XCode"
`osascript -e 'quit app "#{xcodeV}"'`
puts "πŸ’© Deleting Derived Data"
`rm -rf ~/Library/Developer/Xcode/DerivedData/`
puts "πŸ’© Deleting Cache File"
`rm -rf ~/Library/Caches/com.apple.dt.Xcode`
sleep(2)
puts "πŸš€ DONE. Reopening XCode"
`open -a "#{xcodeV}"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment