57
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Xcode の不要ファイルを消す shell script

今までは PC の容量がなくなるたびに「Xcode ファイル 削除」とかでググって以下の記事を参考にしてファイルを消してたけど、それを shell script にしておくとコマンド一発で全部消せて便利。

#!/bin/sh -x

rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Developer/Xcode/Archives
rm -rf ~/Library/Developer/Xcode/DeveloperPortal*
rm -rf ~/Library/Developer/Xcode/DocumentationCache
rm -rf ~/Library/Developer/Xcode/Products
rm -rf '~/Library/Developer/Xcode/iOS DeviceSupport'
rm -rf ~/Library/Developer/XCPGDevices
rm -rf ~/Library/Developer/Shared/Documentation/DocSets
rm -rf '~/Library/Developer/Xcode/iOS Device Logs'
xcrun simctl erase all

rm -rf ~/Library/Caches/com.apple.dt.Xcode

実行権限を付与して実行。

$ chmod 755 xcode_cleanup.sh
$ ./xcode_cleanup.sh

実際にこの shell 動かすと 40GB くらい削除できた。
そのあと Xcode 立ち上げてビルドも問題なし。 (キャッシュが消えたので初回ビルドは時間かかる)

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
57
Help us understand the problem. What are the problem?