【Swift/Carthage】Error:「Could not find module 'Alamofire' for target 'arm64-apple-ios-simulator'; found: arm64-apple-ios」の解決方法!

この記事からわかること
- Swift/Carthageでライブラリ導入時に発生したエラーの解決法
- Error:Could not find module 'Alamofire' for target 'arm64-apple-ios-simulator'; found: arm64-apple-ios"の原因
- ライブラリが読み込めない
index
[open]
\ アプリをリリースしました /
環境
- Xcode:14.2
- Carthage:0.39.0
Could not find module 'Alamofire' for target 'arm64-apple-ios-simulator'; found: arm64-apple-ios
Carthageを使用してライブラリを導入する流れの中でエラーが発生しました。

発生したのはXcode内でプロジェクトディレクトリ内の「Carthageディレクトリ」>「Build」>「iOS」>「ライブラリ.frameworkディレクトリ」を選択します。

さらにこの後の「Run Script」と「Input Files」にも追記し終えてライブラリの導入が完了したと思い、ビルドしようとした際でした。
発生したエラー
Could not find module 'Alamofire' for target 'arm64-apple-ios-simulator'; found: arm64-apple-ios
エラーの原因
Could not find module 'Alamofire' for target 'arm64-apple-ios-simulator'; found: arm64-apple-ios
はビルド時に導入したライブラリがシミュレーター用のアーキテクチャ「arm64-apple-ios-simulator」に対応していないために発生する可能性があるようです。
Could not find module 'Alamofire' for target 'arm64-apple-ios-simulator'; found: arm64-apple-ios
解決方法
私の場合は「Excluded Architectures」に「arm64 ×86_64」を加えることで解決することができました。
解決方法
- Xcode>「Build Settings」>「Excluded Architectures」>「Debug」>「Any iOS Simulator SDK」>「arm64 ×86_64」の追加
- Xcode>「Build Settings」>「Excluded Architectures」>「Release」>「Any iOS Simulator SDK」>「arm64 ×86_64」の追加
Xcodeの「Build Settings」>「Excluded Architectures」から「Debug」と「Release」両方に「Any iOS Simulator SDK」:「arm64 ×86_64」を加えます。本来なら「arm64」のみで良いですが、その後に「×86_64」もないよというエラーが出たので両方とも書いています。

「Excluded Architectures」はビルド時に除外するアーキテクチャを記入する箇所です。
ご覧いただきありがとうございました。