Skip to content

Instantly share code, notes, and snippets.

@rudifa
Last active May 17, 2023 09:38
Show Gist options
  • Save rudifa/0c91ab8e62de0fb135ec94808d27ad53 to your computer and use it in GitHub Desktop.
Save rudifa/0c91ab8e62de0fb135ec94808d27ad53 to your computer and use it in GitHub Desktop.
#!/bin/bash
# originally from
# https://gist.github.com/maciekish/66b6deaa7bc979d0a16c50784e16d697
# rudifa: added TARGET logic and kill CoreSimulatorService
killall Xcode
pkill -int com.apple.CoreSimulator.CoreSimulatorService
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
TARGET=(*.xcworkspace)
if [ $TARGET == "*.xcworkspace" ]; then
TARGET=(*.xcodeproj)
if [ $TARGET == "*.xcodeproj" ]; then
TARGET=""
fi
fi
if [ $TARGET != "" ]; then
open -a "/Applications/Xcode.app" "$TARGET"
else
echo *** no Xcode workspace or project found
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment