Podfile から Pods.xcodeproj の Build Active Architecture Only を NO

ずっと Intel Mac で ReactNative アプリをビルドしていたのですが Apple Silicon な Mac で react-native run-ios しようとすると以下のようなリンクエラーが山ほど出てしまいました。

building for ios simulator-x86_64 but attempting to link with file built for ios simulator-arm64

自分の場合は原因は2つでした。

 

"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64" している

シミュレータ環境では arm64 をビルドするな、という設定ですね。
指定した理由を思い出せないのですが、消します。

 

Pods に対して Build Active Architecture Only の Debug が YES になっている

ここです。(スクショはNoに変更した後)

XCodeから編集しても pod install すると戻ってしまうので、ios/Podfile で対処します。

target 'awesomeApp' do
:
post_install do |installer|
if RUBY_PLATFORM =~ /\Aarm64/
installer.pods_project
.build_configurations
.find {|conf| conf.name == 'Debug'}
.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end