環境
swift version 5.6.1
Xcode 13.3.1
発生した問題
以下エラーが出てビルドが失敗
The operation couldn’t be completed. (SwiftPM.SPMRepositoryError error 3.)
解決した手順
- Xcodeを終了
- ターミナルで以下コマンドを実行
rm -rf ~/Libray/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/org.swift.swiftpm
- Xcodeを起動
- Xcode左上のメニューから [File] -> [Packages] -> [Reset Package Caches]
原因
SPMパッケージのキャッシュが破損したことが原因。