Ali Yousafzai
Ali Yousafzai

Reputation: 61

Expo and React Native Firebase iOS Swift Pods Static Libraries Issue

I was building expo app for IOS and I was getting that error because I had used firebase in my project.

ERROR: [!] 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.

Error: Unknown error. See logs of the Install pods build phase for more information.

I tried many answers from internet but all these were related to react native and pod files etc

Upvotes: 1

Views: 2377

Answers (2)

Nouman Shah
Nouman Shah

Reputation: 143

I encountered the same issue and resolved it by following these steps:

npx expo install expo-build-properties

Add the following in your app.json file:

"plugins": [ "expo-router", "expo-font",

  [
    "expo-build-properties",
    {
      "ios": {
        "useFrameworks": "static",
        "podfileProperties": {
          "use_modular_headers!": true
        }
      }
    }
  ]
],

And you can run npx expo prebuild --clean or npx expo prebuild

Upvotes: 2

Conor Hinchee
Conor Hinchee

Reputation: 53

I ran into this issue when starting a new React Native/Expo Project and integrating React Native Firebase "@react-native-firebase/app": "^20.1.0".

There are two steps to correct this IOS build error:

First, install the expo-build-properties package by running npx expo install expo-build-properties then configure expo-build-properties in app.json plugins to "useFrameworks": "static".

An example from the React Native Firebase Expo Documentation below

"plugins": [
  "@react-native-firebase/app",
  "@react-native-firebase/auth",
  "@react-native-firebase/crashlytics",
  [
    "expo-build-properties",
    {
      "ios": {
        "useFrameworks": "static"
      }
    }
  ]
]

Ensure that you have the Service Account files from your Firebase project downloaded and that the paths for the googleServicesFiles are correct inside the app.json file.

Documentation shows that the app.json looks like this at this point :

{
  "expo": {
    "android": {
      "googleServicesFile": "./google-services.json",
      "package": "com.mycorp.myapp"
    },
    "ios": {
      "googleServicesFile": "./GoogleService-Info.plist",
      "bundleIdentifier": "com.mycorp.myapp"
    },
    "plugins": [
      "@react-native-firebase/app",
      "@react-native-firebase/auth",
      "@react-native-firebase/crashlytics",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

Next, you must tell CocoaPods to use frameworks. Open the file ./ios/Podfile and add these lines right before the use_react_native

  use_frameworks! :linkage => :static

  $RNFirebaseAsStaticFramework = true

  use_react_native!

The final step being to run npx expo run:ios which should result in a successful local IOS build.

Upvotes: 5

Related Questions