将xcode移动到外置硬盘上

我们很多人买的macbook磁盘空间不足,因此我们把占用大户xcode移动到外置硬盘上

1.将 Xcode.app 从 系统的应用程序文件夹拖动到移动硬盘中的某个文件夹。

mv /Applications/Xcode.app /Volumes/mindata/Applications

2.更新工具链路径

sudo xcode-select -s /Volumes/mindata/Applications/Xcode.app/Contents/Developer

2.移动所有的缓存数据到移动硬盘上


mkdir -p /Volumes/mindata/Applications/XcodeData
mkdir -p /Volumes/mindata/Applications/XcodeData/DerivedData
mkdir -p /Volumes/mindata/Applications/XcodeData/CoreSimulator
mkdir -p /Volumes/mindata/Applications/XcodeData/Archives
# 移动 DerivedData
mv ~/Library/Developer/Xcode/DerivedData /Volumes/mindata/Applications/XcodeData/DerivedData

# 移动 CoreSimulator
mv ~/Library/Developer/CoreSimulator /Volumes/mindata/Applications/XcodeData/CoreSimulator

# 移动 Archives
mv ~/Library/Developer/Xcode/Archives /Volumes/mindata/Applications/XcodeData/Archives
# 为 DerivedData 创建符号链接
ln -s /Volumes/mindata/Applications/XcodeData/DerivedData ~/Library/Developer/Xcode/DerivedData

# 为 CoreSimulator 创建符号链接
ln -s /Volumes/mindata/Applications/XcodeData/CoreSimulator ~/Library/Developer/CoreSimulator

# 为 Archives 创建符号链接
ln -s /Volumes/mindata/Applications/XcodeData/Archives ~/Library/Developer/Xcode/Archives

3.6. 重启 Xcode 并测试

重新打开 Xcode,尝试进行编译和运行。Xcode 应该能正常使用移动硬盘上的缓存和数据。

关于Zeno Chen

本人涉及的领域较多,杂而不精 程序设计语言: Perl, Java, PHP, Python; 数据库系统: MySQL,Oracle; 偶尔做做电路板的开发,主攻STM32单片机
此条目发表在Mac分类目录。将固定链接加入收藏夹。