33
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SwiftPackageManagerで導入したパッケージの読み込みを高速化する

Posted at

SwiftPMで導入したパッケージの読み込みが遅い

という経験ありませんか?
Xcodeを開いてから編集可能になるまで数分待っているみたいなこともあると思います。
特にFirebaseとかgrpcとか入れていくとどんどん遅くなっていきます。
これらは依存解決に時間がかかっているように見えます。
しかも失敗したらReset Package Cachesしてやり直しです。

CleanShot 2022-01-01 at 16.46.26@2x.png

なぜかxcodebuildで依存性の解決をすると早い

Xcodeのコマンドであるxcodebuildでもswiftpmの依存解決が出来るのですが、実はこっちを使うと早く終わるケースがあります。
自分の環境では20~30%ほど早くなり、失敗することも無くなりました。

$ xcodebuild -resolvePackageDependencies

zshでエイリアスを貼る

普段はXcodeをxedコマンドで開いているのですが、開く前に上記のxcodebuild を走らせるxxedエイリアスを定義してみます。

zshrc
# xed extension
alias xxed="xcodebuild -resolvePackageDependencies && xed"

これでxxedでプロジェクトを開くとすぐに編集可能になりました。

33
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?