清除Xcode缓存,脚本自动删除

因为懒,所以有了这个脚本,自动清除Xcode缓存
现在是会清除三个文件夹
~/Library/Developer/CoreSimulator/Devices/ (模拟器及安装的app)
~/Library/Developer/Xcode/Archives (打包文件夹)
~/Library/Developer/Xcode/DerivedData (Xcode 编译缓存)

注意⚠️⚠️⚠️ 脚本中第三个清除模拟器后,需要重启电脑,否则Xcode会报错,找不到模拟器

下载地址

脚本下载地址cleanXcode.sh

使用方法:

拖到终端运行

脚本授权报错

permission denied

cd 到脚本文件夹 运行

chmod +x ./*

然后从新拖动脚本到终端

源码

#!/bin/bash
#--------------------------------------------
# author:小小强
#--------------------------------------------
echo "========开始清除Xcode========"
echo 
read -p "Are you sure? [yes/NO] " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo 
    exit 1
fi
echo 
echo "开始清除DerivedData..."
rm -rf ~/Library/Developer/Xcode/DerivedData
echo "DerivedData已清除"
echo 
read -p "是否要删除Archives,Xcode打包文件 [yes/NO] " -n 1 -r
if [[  $REPLY =~ ^[Yy]$ ]]
then
echo 
echo "开始清除Archives..."
rm -rf ~/Library/Developer/Xcode/Archives
echo "Archives已清除"
fi
echo 
read -p "是否要删除运行xcode后在模拟器上安装的app?⚠️⚠️⚠️ 此文件夹删除后需要重启Xcode [yes/NO] " -n 1 -r
if [[  $REPLY =~ ^[Yy]$ ]]
then
echo 
echo "开始清除运行xcode后在模拟器上安装的app..."
rm -rf ~/Library/Developer/CoreSimulator/Devices
echo "模拟器上安装的app已清除"
echo "CoreSimulator文件夹删除后请重启Xcode"
fi
echo ""

你可能感兴趣的:(清除Xcode缓存,脚本自动删除)