LoginSignup
0
2

Excluded Architectures:arm64とSwiftPackageManagerで、Compiled module was created by a different version of the compiler; rebuild 'SOME_LIBRARY' and try again: /PATH_TO_SOME_LIBRARY.swiftmodule/x86_64-apple-ios-simulator.swiftmodule エラー

Last updated at Posted at 2023-05-12

Apple SilliconのMacでシミュレータをビルド対象にしてSwift Package Manager(以下SPM)で追加したライブラリをりようすると、import 文の場所で以下のエラーが発生します。

Compiled module was created by a different version of the compiler; rebuild 'SOME_LIBRARY' and try again: /PATH_TO_SOME_LIBRARY.swiftmodule/x86_64-apple-ios-simulator.swiftmodule

以下のような状況になっていて、この問題が発生していると考えられます。

  • Excluded Architecturesにarm64を指定している
  • Apple SilliconのMacでSPMで追加したライブラリはシミュレータを対象にすると、シミュレータがarm64なのでarm64用のバイナリのみ作成する
  • プロジェクト全体の設定としてはarm64を除外しているので、PRMで追加したパッケージもx86_64のバイナリが必要で探しにいく
  • でも見つからなくてエラー

解決方法

Excluded Architecturesのarm64を外すのがベストだと思いますが、おそらくいろいろな事情ですんなり外せないことがおおいと思います。
そこでXcode14.3ではSimulatorのみRossettaモードで起動できる機能があるので、ビルド対象のSimulatorをRossetaにすることで解決します。Xcode自体はRossetaモードではないので許容範囲ではないでしょうか?

Product > Destination > Destination Architectures から有効にすることができます。

image.png

有効にするとsimulator名に (Rosseta) がついたシミュレータが選択できるようになります。
image.png

まとめ

長いことこの問題に苦労した人は多いのではないでしょうか? Xcode自体をRossetaモードにしなくて良くなったので、Swift Package Managerの利用がしやすくなる気がします。

参考

0
2
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
0
2