ExpoのiOSビルド時に出るビルドエラーの対処法【ReactNative】

ExpoのiOSビルド時にエラーはつきものですが、以下のようなエラーは出てないでしょうか。

エラー① <FirebaseCoreInternal , FirebaseStorageのエラー>

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `FirebaseCoreInternal` depends upon `GoogleUtilities`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

The Swift pod `FirebaseStorage` depends upon `FirebaseAppCheckInterop`, `FirebaseAuthInterop`, `FirebaseCore`, `FirebaseCoreExtension`, and `GTMSessionFetcher`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

エラー② <import of module 'glog.glog.log_severity' appears within namespace 'google'>

❌ (ios/Pods/Headers/Public/glog/glog/logging.h:512:1) 510 | 511 | // They need the definitions of integer types. > 512 | #include "glog/log_severity.h" | ^ import of module 'glog.glog.log_severity' appears within namespace 'google' 513 | #include "glog/vlog_is_on.h" 514 | 515 | // Initialize google's logging library. You will see the program name

エラー③ <FirebaseStorage/FirebaseStorage-Swift.h' file not found>

(ios/Pods/Headers/Private/Firebase/Firebase.h:78:13) 76 | 77 | #if __has_include("FirebaseStorage-umbrella.h") > 78 | #import <FirebaseStorage/FirebaseStorage-Swift.h> | ^ 'FirebaseStorage/FirebaseStorage-Swift.h' file not found 79 | #endif 80 | 81 | #endif // defined(__has_include)

これらのエラーはそれぞれあなたが書いたコードに問題があるわけではなく、iOSのPodや依存関係に問題がある場合がある可能性が高いです。

このエラーでしばらくはまっていたので、この3つのエラーについての対処法を紹介していくので、もしexpo の iOSビルドで立ち止まっている人がいるならば、確認してみてください!

対処法Ⅰ【Podfileを編集する】

FirebaseCoreInternal , FirebaseStorage を react-native-firebase を使っている方にこのエラーがでます。

エラー文では、

you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

Podfileの中に、`use_modular_headers!`を入れてね。または、:modular_headers => trueで特定の依存関係を指定してね。

と書いてあります。

なので、expoファイルの中のPodfileを見てみましょう。

Podfileは2つある。間違わないように注意して!

Expoプロジェクトの中には、実はPodfileは二つあります。

↓この階層が正しい編集するべきPodfileの場所です。

あなたのプロジェクト>ios>Podfile

もう一つは、node_modules>react-native>templates>ios>Podfileにありますが、間違わないでください。

正しいPodfileの中には、以下のようにtargetにあなたのプロジェクト名がきちんと書いてあるはずです。そこでも区別することができます。

target あなたのプロジェクト名 do

Podfileの修正箇所

①:flipper_configurationをコメントアウトする。

Podfileを開いたら、以下のようなflipper_configurationを探します。

それをコメントアウトしましょう。

:flipper_configuration
あべべ

行の最初に#でコメントアウトができます。

②use_frameworks!を加える。

次に、Podfile内のtarget 'onsen_matching' do の下に、use_frameworksを入れます。

target 'プロジェクト名' do
  use_expo_modules!
  #以下を書き加える。
  use_frameworks!

元々、use_expo_modules!書き込まれている場合がありますが、そちらはコメントアウトしないで残しておいてください。

あべべ

ここまでのPodfileの編集ができたら、まずはビルドしてみてください。

対処法② 依存関係の更新

依存関係が更新されていない場合があります。

以下の手順に沿って依存関係を解消してください。

Expoプロジェクトの更新

ターミナルで以下のコマンドを実行します。

expo update

Expoプロジェクトにおいて適切なバージョンのReact Nativeとその他の依存関係をインストールしてくれます。

npm パッケージの再インストール

以下のコマンドを実行して、node_modulesディレクトリとパッケージのロックファイルを削除し、依存関係を再インストールします。

rm -rf node_modules/
rm -f package-lock.json yarn.lock
npm install 或いは yarn install

CocoaPodsのインストール

iOSディレクトリに移動し、CocoaPodsの依存関係をインストールします。。

cd ios/
pod deintegrate
pod install
あべべ

ここまでできたら、再度ビルドしてみてください。

まとめ

以上で、エラーの対処法になります。

今回は、Expo のiOSビルドで失敗する時の陥りやすいエラーの一つの対処法を紹介しました。

Expoの無料ビルド回数は決まってるので、ビルドしすぎないように注意しましょうね。

では、また!

(Visited 614 times, 1 visits today)