Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirebasePlugin.h:4:9: fatal error: module 'FirebaseFirestore' not found #735

Closed
jpdelmundo opened this issue May 27, 2022 · 30 comments
Closed

Comments

@jpdelmundo
Copy link

jpdelmundo commented May 27, 2022

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
@subbuy
Copy link

subbuy commented May 28, 2022

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.

@FalconKul
Copy link

FalconKul commented May 30, 2022

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

@Delagen
Copy link

Delagen commented May 31, 2022

Created PR. Because I spent several hours to figure it out. Thanks @FalconKul

@jpdelmundo
Copy link
Author

jpdelmundo commented May 31, 2022

EDIT: For some reason, this is not working for me anymore. Use @FalconKul's suggestion above. I'm leaving this here in case it might be helpful to some.

So, I discovered a workaround, at least in my case. I am using an M1 Mac and I saw a suggestion to run Xcode on Rosetta. After I doing that, Xcode now successfully builds the app.

Basically:

  1. Quit Xcode if it's running
  2. Open the Applications folder
  3. Right-click on Xcode
  4. Choose Get Info (there's maybe another step to see the "Get Info" option)
  5. Tick/check on "Open using Rosetta"
  6. Run Xcode again to build the app (or your cordova build cli)

@dpa99c
Copy link
Owner

dpa99c commented May 31, 2022

Seems like this issue might be specific to Apple Silicon: invertase/firestore-ios-sdk-frameworks#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:
#407

This was resolved by using a git repo which contains a pre-compiled version of Firestore which significantly decreases build time:
#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.

@dpa99c
Copy link
Owner

dpa99c commented May 31, 2022

I am using an Intel-based Mac and [email protected] using Firebase iOS SDK v9.1.0 builds fine for me so I'm still thinking the issue is specific to Apple Silicon.

Can someone with an M1 Mac try adding use_frameworks! to the Podfile and see if that resolves the issue?
It's documented as a breaking change in the Firebase iOS SDK v9.0.0 release notes but doesn't seem required for an Intel Mac so maybe it's a specific requirement for Apple Silicon Macs.

@tzappia
Copy link

tzappia commented May 31, 2022

@dpa99c note you already have <pods use-frameworks="true"> in plugin.xml, so use_frameworks! is already being added to the Podfile.

On my M1 Mac, I get this error using cordova build, but my build runs successfully in Xcode immediately afterwards without making any code changes or using Rosetta. I am using branch 14.1.0-cli

/Users/tzappia/workspace/tovi/app/platforms/ios/TOVI/Plugins/cordova-plugin-firebasex/FirebasePlugin.h:4:9: fatal error: module 'FirebaseFirestore' not found
@import FirebaseFirestore;
 ~~~~~~~^~~~~~~~~~~~~~~~~
1 error generated.

@Birowsky
Copy link

Birowsky commented Jun 1, 2022

I have this issue on GitHub Actions - Mac runner. They don't use M1, do they?

@jpdelmundo
Copy link
Author

This was resolved by using a git repo which contains a pre-compiled version of Firestore which significantly decreases build time:
#440

@dpa99c Is there a pre-compiled version for Apple Silicon, if none, then this is still a problem. Now, if there is a pre-compiled version for Apple Silicon, is it the version being installed by cocoapods?

It looks like @FalconKul's suggestion above is still the solution to this.

@pinguluk
Copy link

pinguluk commented Jun 7, 2022

EDIT: For some reason, this is not working for me anymore. Use @FalconKul's suggestion above. I'm leaving this here in case it might be helpful to some.

So, I discovered a workaround, at least in my case. I am using an M1 Mac and I saw a suggestion to run Xcode on Rosetta. After I doing that, Xcode now successfully builds the app.

Basically:

  1. Quit Xcode if it's running
  2. Open the Applications folder
  3. Right-click on Xcode
  4. Choose Get Info (there's maybe another step to see the "Get Info" option)
  5. Tick/check on "Open using Rosetta"
  6. Run Xcode again to build the app (or your cordova build cli)

This method builds the app fine on emulators , but the app itself is stuck on the splashscreen, without any error

@roundlakedan
Copy link

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.

@jpdelmundo
Copy link
Author

@pinguluk

This method builds the app fine on emulators , but the app itself is stuck on the splashscreen, without any error

I had this same problem. What worked for me is to also set Simulator to open using Rosetta (if that's what you mean by emulator).

@Franco-Alejandro
Copy link

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)

@Franco-Alejandro
Copy link

Franco-Alejandro commented Jun 17, 2022

Ok, so far I had to use the pod directly, because it was blocking my update.

I've tried a couple of things that did not work. A weird thing that did happen to me was that the build DID WORK on an emulator and my device. But when I tried building the ipa for release, it got stuck here.

@Delagen
Copy link

Delagen commented Jun 17, 2022

How many hours do people spend trying to correct this issue? Is it worth of 15 minutes of compilation on some old PC?
#737 (comment)

@raymondelferink
Copy link

I have tried all the suggestion, but to no avail. Version 14.0.0 works fine, 14.1.0 doesn't. I use the same macbook pro (2019), same code, same everything. Both versions use the pre-compiled version of the Firestore Pod mentioned here: #737 (comment)
This is not my cup of tea, so I'm reverting to v14.0.0 for now. I'll keep an watching this space though:-)

@Franco-Alejandro
Copy link

Franco-Alejandro commented Jun 17, 2022

would it be possible that the error is not the plugin itself but rather the pre-compiled version of the pod?

@peitschie
Copy link

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...

@ZaLiTHkA
Copy link

ZaLiTHkA commented Jul 11, 2022

@peitschie do you know of a way to do that within a CI environment? I'm trying to release an update to a mobile app, but I don't have access to a Mac, so I can only build for iOS in the cloud (aka: on somebody else's machine).

FWIW: I'm currently using Ionic Appflow, looking to switch to CodeMagic soon.

@peitschie
Copy link

peitschie commented Jul 11, 2022

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,
    });
  }
};

@ZaLiTHkA
Copy link

thanks so much for the prompt response.. 👍🏼

Added to ios platform in config.xml:

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

however, Appflow is making things stupendously difficult here:

Cordova hooks are specified in your config.xml and when used with the Cordova CLI will execute scripts. Appflow however uses Gym to compile your Application, so Cordova hooks will not run with the exception of after_platform_add and after_prepare.

[source]


just for the sake of testing, I switched the hook trigger from before_prepare to after_platform_add, thinking along the lines of "the platform needs to be added first anyway, so maybe this will happen before the 'prepare' stage. however, this simply results in a different error:

▸ Compiling FirebasePlugin.m

⚠️  /Users/ionic-cloud-team/builds/<GITLAB_PATH_REDACTED>/platforms/ios/LIVE!/Plugins/cordova-plugin-firebasex/FirebasePlugin.h:8:49: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]

- (void)setAutoInitEnabled:(CDVInvokedUrlCommand*)command;
                                                ^

I don't want to hijack this issue with discussions regarding Cordova Hooks in Ionic Appflow, so I'll go do some more digging now and see what else I can find.

@peitschie
Copy link

wait!! I mis-typed that... should be after_prepare

Can you see if this works?

@ZaLiTHkA
Copy link

ZaLiTHkA commented Jul 11, 2022

wait!! I mis-typed that... should be after_prepare

Can you see if this works?

ah, yes.. that executed the hook and fixed the Compiling FirebasePlugin.m step, but then after completing all the compilation steps, it fails later on with the message symbol(s) not found for architecture arm64.


one interest point, considering the reference here to IPHONEOS_DEPLOYMENT_TARGET, is that the final build process summary includes the following output:

** ARCHIVE FAILED **


The following build commands failed:
	Ld /Users/ionic-cloud-team/Library/Developer/Xcode/DerivedData/LIVE!-biiogavgulafuibvvxxkerkrmsir/Build/Intermediates.noindex/ArchiveIntermediates/LIVE!/InstallationBuildProductsLocation/Applications/LIVE!.app/LIVE! normal (in target 'LIVE!' from project 'LIVE!')
(1 failure)
[08:13:01]: Exit status: 65

+---------------+-------------------------+
|            Build environment            |
+---------------+-------------------------+
| xcode_path    | /Applications/Xcode.app |
| gym_version   | 2.205.1                 |
| export_method | app-store               |
| sdk           | iPhoneOS15.0.sdk        |
+---------------+-------------------------+

[08:13:01]: ▸      (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibilityConcurrency_$_FirebaseFirestoreSwift)
[08:13:01]: ▸ ld: symbol(s) not found for architecture arm64
[08:13:01]: ▸ clang: error: linker command failed with exit code 1 (use -v to see invocation)
[08:13:01]: ▸ /Users/ionic-cloud-team/builds/<GITLAB_PATH_REDACTED>/platforms/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'AppAuth' from project 'Pods')

I'm going to try this again now with explicitly setting the deployment-target preference to 11.0 (edit: can't use 9.0 because cordova-ios is on 6.2.0) for the iOS platform in my cordova.xml, just wanted to mention it here as well, in case it's relevant.

@peitschie
Copy link

@ZaLiTHkA that sounds related to this: invertase/firestore-ios-sdk-frameworks#52
I suspect you can extend the hook above to apply similar steps as the patch there.

@ZaLiTHkA
Copy link

ZaLiTHkA commented Jul 11, 2022

FWIW: setting the iOS platform deployment-target preference to 11.0 didn't change anything from my previous message..

@ZaLiTHkA that sounds related to this: invertase/firestore-ios-sdk-frameworks#52 I suspect you can extend the hook above to apply similar steps as the patch there.

..so I will dig into this one now then.

thank you for the assistance, greatly appreciate it. 🖖🏼


edit: quick follow-up, I actually ended up switching my app from this plugin over to cordova-plugin-firebase-messaging just to get an urgent release out.. suffice to say I found some zero-day bugs on release that just couldn't wait.

anyways, this is probably not a permanent switch as I do have plans to integrate other Firebase services as well, so I'll still keep tracking this issue. if anyone needs help with testing production builds in Ionic Appflow or (soon) CodeMagic, please do mention me and I'll see what I can do. 👍🏼

@Leffe108
Copy link

Leffe108 commented Jul 11, 2022

I face the same issue with FirebaseFirestore while compiling for iOS after updating from 13.0.1 to 14.1.0 as I had updated (android) target SDK to 31 and got errors for android:exported in AndroidManifest.xml that a newer firebasex had fixed.

Edit: I did some tests with going back and 13.0.1 do compile for iOS without this issue. 14.0.0 fails to compile for iOS with the same issue as in 14.1.0.

@peitschie
Copy link

@Leffe108 this workaround here should fix the issue for you: #735 (comment)

@dpa99c dpa99c closed this as completed in d1fb68a Jul 20, 2022
@dpa99c
Copy link
Owner

dpa99c commented Jul 20, 2022

[email protected] 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.

@aliexalter
Copy link

How can I fix this error on ionic appflow ?
I am using 4.2.0-cli version.

@dpa99c
Copy link
Owner

dpa99c commented Jul 22, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.