cordova-plugin-firebasex: FirebasePlugin.h:4:9: fatal error: module 'FirebaseFirestore' not found

cordova: 11.0.0 cordova-ios: 6.2.0 cordova-plugin-firebasex: 14.1.0 (also tried 14.1.0-cli) xcode: 13.4

Error:

In file included from /Users/< user >/< project >/cordova/platforms/ios/< app name >/Plugins/cordova-plugin-firebasex/AppDelegate+FirebasePlugin.m:2: /Users/< user >/< project >/cordova/platforms/ios/< app name >/Plugins/cordova-plugin-firebasex/FirebasePlugin.h:4:9: fatal error: module ‘FirebaseFirestore’ not found @import FirebaseFirestore;

Tried the following but didn’t fix it:

  • pod repo update then pod install in the platforms/ios dir
  • pod deintegrate and pod install
  • cordova platform rm/add ios
  • cordova plugin rm/add cordova-plugin-firebasex
  • cordova clean
  • Xcode clean build folder

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 30 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I have seen the same issue, I resolve it by manually changing Podfile to force download Firestore. Below is my step to resolve it:

  1. Goto platform/ios and remove Podfile.lock
  2. Remove Pods folder
  3. Open Podfile and replace pod 'FirebaseFirestore', :tag => '9.1.0', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git' by pod 'Firebase/Firestore', '9.1.0'
  4. pod install

I think the issue occurs because pod 'FirebaseFirestore', :tag => '9.1.0', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git does not contains FirebaseFirestore module

Sorry for my bad English

cordova-plugin-firebasex@14.2.0 has just been published to npm and should resolve this. By default, the plugin will now use the standard pod for Firestore unless you optionally specify the plugin variable IOS_USE_PRECOMPILED_FIRESTORE_POD=true at install time, in which case the pre-compiled version will be used.

If you have issues with an existing project, run these commands from platforms/ios/ as suggested here:

pod deintegrate
pod setup
pod install

Note that in the version you can also specify IOS_FIREBASE_SDK_VERSION to override the version of the Firebase iOS SDK pinned in plugin.xml.

So… some progress here, this seems to be tied to the iOS deployment target for the FirebaseFirestore being iOS 10.0. If I go into the cordova workspace file and manually bump JUST this dependency to iOS 11.0, then this all builds correctly:

image

I’ll update if I get a better way to set this automatically…

@aliexalter This plugin (as noted) relies on Cordova Hook scripts to configure the native platform projects. Ionic Appflow does not support all of the hooks used by this plugin so it may not work correctly in that build environment.

I’m using intel and I’m running into this error when trying to archive from Xcode, I’ll update if I find something (using this plugin on the latest version)

Just to clarify previous comments/suggestions - I’m still doing my builds on an Intel-based mbp and it’s throwing the “Module ‘FirebaseFirestore’ not found” error when I try to analyze the app. I’m able to build it, and even run it on my local device. But I can’t get it uploaded to the app store as it won’t pass basic checks.

cordova: 11.0.0 cordova-ios: 6.2.0 cordova-plugin-firebasex: 14.1.0 (also tried 14.1.0-cli) xcode: 13.4

Error:

In file included from /Users/< user >/< project >/cordova/platforms/ios/< app name >/Plugins/cordova-plugin-firebasex/AppDelegate+FirebasePlugin.m:2: /Users/< user >/< project >/cordova/platforms/ios/< app name >/Plugins/cordova-plugin-firebasex/FirebasePlugin.h:4:9: fatal error: module ‘FirebaseFirestore’ not found @import FirebaseFirestore;

Tried the following but didn’t fix it:

  • pod repo update then pod install in the platforms/ios dir
  • pod deintegrate and pod install
  • cordova platform rm/add ios
  • cordova plugin rm/add cordova-plugin-firebasex
  • cordova clean
  • Xcode clean build folder

Ran into same issue. Went back to cordova-plugin-firebasex: 14.0.0 and seems to compile in xcode.

Not the prettiest… but here’s a cordova hook that does the job for me:

Added to ios platform in config.xml:

<hook src="hooks/firebaseDeploymentTargetFix.js" type="after_prepare" />

In a file in hooks/firebaseDeploymentTargetFix.js in the root of your cordova project:

#!/usr/bin/env node

// Workaround for https://github.com/dpa99c/cordova-plugin-firebasex/issues/735
// FirebaseFirestore appears to require iOS deployment target >= 11.0

const fs = require("fs");
const path = require("path");
const execa = require("execa");

module.exports = (context) => {
  const platformPath = path.resolve(context.opts.projectRoot, "platforms/ios");
  const podfilePath = path.resolve(platformPath, "Podfile");

  if (!fs.existsSync(podfilePath)) {
    console.log(`'${podfilePath}' does not exist. Firebase deployment fix skipped.`);
    return;
  }

  let podfileContent = fs.readFileSync(podfilePath, "utf-8");
  if (podfileContent.indexOf("post_install") == -1) {
    podfileContent += `

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'FirebaseFirestore'
      target.build_configurations.each do |config|
        config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      end
    end
  end
end`;

    fs.writeFileSync(podfilePath, podfileContent, "utf-8");

    return execa("pod", ["install", "--verbose"], {
      cwd: platformPath,
    });
  }
};

How many hours do people spend trying to correct this issue? Is it worth of 15 minutes of compilation on some old PC? https://github.com/dpa99c/cordova-plugin-firebasex/pull/737#issuecomment-1141884263

Seems like this issue might be specific to Apple Silicon: https://github.com/invertase/firestore-ios-sdk-frameworks/issues/51

The reason for not using the Firestore Pod directly from the Firebase SDK is that it needs to be compiled from scratch which can take a very long time - upwards of 30 minutes on an old Mac: https://github.com/dpa99c/cordova-plugin-firebasex/issues/407

This was resolved by using a git repo which contains a pre-compiled version of Firestore which significantly decreases build time: https://github.com/dpa99c/cordova-plugin-firebasex/pull/440

But it seems from the issue raised against firestore-ios-sdk-frameworks there might be a problem with this on Apple Silicon. Hence running in Rosetta resolves it as it will handle code compiled for Intel architecture.