4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

React NativeでDynamic Linksを設定する際のPod installエラー「The Swift pod FirebaseCoreInternal depends upon GoogleUtilities」の解決方法」

Posted at

React Nativeでアプリ開発を行う際には、Firebaseを使用することがあります。Firebaseは、ユーザー認証やデータベース管理、通知機能など、多数の機能を提供しています。その中でも、Dynamic LinksはFirebaseの強力な機能の一つであり、アプリ内のコンテンツに対して、スマートにユーザーを誘導することができます。

しかし、React NativeでDynamic Linksを設定する際には、iOSのFirebase SDKを導入する過程で、エラーが発生することがあります。このエラーは、Firebase SDKが依存するGoogleUtilitiesが、モジュールを定義していないために発生します。本記事では、このエラーを解決する方法について説明します。

問題の再現方法

以下の手順で、React NativeでDynamic Linksを設定しようとすると、エラーが発生することがあります。

まず、React Nativeプロジェクトのルートディレクトリで、以下のコマンドを実行します。

# Install & setup the app module
yarn add @react-native-firebase/app

# Install the dynamic-links module
yarn add @react-native-firebase/dynamic-links

次に、以下のコマンドを実行して、iOSのFirebase SDKをインストールします。

npx pod-install

上記コマンドを実行すると、以下のようなエラーメッセージが表示されます。

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. Couldn't install Pods. Updating the Pods project and trying again... Command `pod install` failed.

原因の解説

このエラーは、Firebase SDKが依存するGoogleUtilitiesが、モジュールを定義していないために発生します。これにより、SwiftからGoogleUtilitiesをimportする際にエラーが発生します。

Firebaseの公式ドキュメントによると、GoogleUtilitiesをモジュールとして使用するには、use_modular_headers!をグローバルに設定するか、modular_headers => trueを特定の依存関係に指定する必要があります。

解決策

iOSのFirebase SDKが依存するGoogleUtilitiesが、モジュールとして定義されるように、Podfileに以下のコードを追加します。

+ pod 'Firebase', :modular_headers => true
+ pod 'FirebaseCore', :modular_headers => true
+ pod 'GoogleUtilities', :modular_headers => true
+ $RNFirebaseAsStatic

end
4
0
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
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?