Cordova-plugin-firebasex: iOS builds fail if first build is from CLI

Created on 30 Jun 2019  路  31Comments  路  Source: dpa99c/cordova-plugin-firebasex

Thanx a ton for reviving this plugin!

I managed to make it work for android, as described here.

However, I fail to do so for ios.

When I run cordova run ios, the app starts and immediately crashes.

When I try to run it from xCode, this is what I get:

Screen Shot 2019-06-30 at 12 02 07

bug investigate

All 31 comments

Some extra info:

When running cordova platform add [email protected] I get this:

[!] The 屑芯褬效芯械泻 [Release] target overrides the LD_RUNPATH_SEARCH_PATHS build setting defined in `Pods/Target Support Files/Pods-屑芯褬效芯械泻/Pods-屑芯褬效芯械泻.release.xcconfig'. This can lead to problems with the CocoaPods installation

  • Use the $(inherited) flag, or
  • Remove the build settings from the target.

I believe that's coming from the build.json config, documented here.

Same here

As documented this fork of cordova-plugin-firebase has been migrated to use Cocoapods to satisfy the iOS Firebase SDK dependencies.

This requires you to have Cocoapods installed and updated as instructed.

If building your project in Xcode, you need to open YourProject.xcworkspace (not YourProject.xcodeproj) so both your Cordova app project and the Pods project will be loaded into Xcode.

Clone and build the test project to validate your build environment.

@dpa99c all good. Didn't have to do anything. Just ran these:

cordova platform add ios
cordova run ios

Screen Shot 2019-06-30 at 23 00 34

If the test project is building & running OK, then you're build env is fine so there must be something in your other project which is causing the problem.
Make sure to clear down and completely rebuild the iOS platform:

rm -Rf platforms/ios plugins/ node_modules/
npm install
cordova platform add ios@latest

Yeah.. I've done that dozen times.. still got the same behavior. There has to be a plugin conflict. Do you have a magic technique to identify those?

The error you posted in Xcode indicates GTMSessionFetcher library was not found.
This is a downstream dependency of the Firebase SDK on iOS so should be satisfied by Cocoapods during the build.

So I would check the console output for any errors after running cordova platform add ios and cordova build ios for any errors.

Also check if any of your included plugins themselves use Cocoapods to satisfy library dependencies and if so check that the libraries and versions don't conflict with this plugin.
(you can look at the plugin.xml of each plugin in plugins/ and check for <pod> or <framework type="podspec">).

What solved the issue for me was adding the $(inherited) to Library Search Path as mentioned over here:
https://stackoverflow.com/questions/24050012/error-library-not-found-for

@yosikal are you referring to this answer? How does that translate in cordova setup?

I don't wanna be modifying uncommitable sources.

@Birowsky I've captured this as #25

@dpa99c awesomeness.

Just published [email protected] which contains a fix to ensure $(inherited) is always present in the search path. Please give it a try.

I'm experiencing the same exact behavior.

I can confirm that $(inherited) has been added here:
Screen Shot 2019-07-01 at 11 27 37

But I see no changes here:
Screen Shot 2019-07-01 at 11 29 48

Since the test project works fine in your build environment, I would guess another plugin in your project is conflicting with this one.

GTMSessionFetcher is named in the error, so I would first look to see if any other plugins specify that library as a podspec.
If not, find if any other podspecs specified by plugins in your project as these may have a sub-dependency which is conflicting with the pods pulled in by Firebase SDK v6.3.0

I have same problem (3.0.7)
``` "dependencies": {
"cordova-ios": "^5.0.1",
"cordova-plugin-android-permissions": "^1.0.0",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-appcenter-analytics": "^0.3.2",
"cordova-plugin-appcenter-crashes": "^0.3.2",
"cordova-plugin-appcenter-shared": "^0.3.2",
"cordova-plugin-cocoapod-supportx": "^1.7.2",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-firebasex": "^2.1.0",
"cordova-plugin-geolocation": "^4.0.1",
"cordova-plugin-inappbrowser": "^3.0.0",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.1.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-vibration": "^3.1.0",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-file": "^4.3.3",
"cordova-plugin-file-transfer": "^1.6.3",
"cordova-plugin-zip": "^3.1.0",
"cordova-plugin-code-push: "^1.11.18",

},
```

@AMerkuri I recommend cloning and building the test project then adding each of the plugins above one-at-a-time, building & running after each, to identify which plugin(s) cause the conflict.

I guess I'll need to do that some day. As a temporary workaround I have downgraded cordova-ios to 5.0.0.

I finally managed to localize the problem.

In the test project, change the <name>FirebaseTest</name> with something outside the latin alphabet, eg: <name>泻褉芯屑懈写</name>.
Save and run cordova prepare && cordova build ios, and expect it to fail with something like:

ld: framework not found Pods_______

Phew. Does it look fixable?

I see that some sort of namespace is created based on the app name, but somewhere along the way, the encoding does not translate properly.

@AMerkuri does your app have a non-latin name?

@yosikal are you referring to this answer? How does that translate in cordova setup?

I don't wanna be modifying uncommitable sources.

I'm referring to the accepted answer. I added $(inherited) to Library Search Path.

@Birowsky
I have latin with all uppercase. My iOS project started to work when I downgraded corodova-ios from 5.0.1 to 5.0

@Birowsky I didn't notice your project name contained non-latin characters - this is a known issue with Xcode/Cocoapods - see https://github.com/dpa99c/cordova-plugin-firebase/issues/18.
Any reason you can't make the project name in latin?

@AMerkuri maybe a bug in [email protected]?

@yosikal this should be done by default now: https://github.com/dpa99c/cordova-plugin-firebase/commit/2d86a2647e97a2b126914b9c5af046d923a6257b

Aight Dave, I'm done with the renaming, no problem there.

However I'm hitting the next wall. And I have a minimal reproducible config for ya:

  • clone the test project
  • place the build.json "automatic signing" sample config from cordova's docs, at the top level of the project
  • run cordova prepare && cordova build ios
  • expect it to fail with:

ld: library not found for -lPods-FirebaseTest
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Makes me wonder, why did you not notice this? Do you not use the build.json config to build release versions of your apps?

Normally I build via Xcode so I can upload direct to App Store (Archive > Upload) or test on devices/simulators so I hadn't noticed this issue.

However I followed your steps above and I can reproduce the issue.
If I then open the .xcworkspace in Xcode, the build still fails.

Interestingly if I re-add the iOS platform (rm -Rf platforms/ios/ && cordova platform add ios && cordova prepare ios) then open the .xcworkspace in Xcode, configure signing details in Xcode, then build in Xcode, then build succeeds.
After that, I can then do cordova build ios and cordova build ios --release and they both succeed.
So you can use this as a workaround in the meantime.

I believe that the Xcode project is somehow being misconfigured by Cordova on the initial CLI build because if the initial build is done via Xcode, the first build (and subsequent builds) then succeed.

It may be related to this issue: https://github.com/blakgeek/cordova-plugin-cocoapods-support/issues/9
After all this project depends of cordova-plugin-cocoapod-supportx which is derived from cordova-plugin-cocoapod-support.

Further evidence that the Cordova build is the cause in this comment which indicates building the workspace with fastlane succeeds.

So I don't think this issue is caused directly by this plugin (cordova-plugin-firebasex) but on its dependency on cordova-plugin-cocoapod-supportx.

The question is whether I can do anything to resolve the issue in cordova-plugin-cocoapod-supportx.
[email protected] adds implicit support for Cocoapods and I've been testing with [email protected] but I don't think I can remove the dependency on cordova-plugin-cocoapod-supportx for [email protected] because I added additional functionality (e.g. support for plugin variables in <podspec>) which I'm not sure cordova-ios@5 supports.

When I can make some time, I'll try to create an isolated test case using cordova-plugin-cocoapod-supportx and see if there's a way to fix this.

Sorry, I wish I could help with any of this, but I only have shallow knowledge of the platform-specific intricacies. I'm hoping that Cordova can keep it that way for the forceable future :}

The reason I'm not at liberty to switch to xCode for deploys, but rely on build.json, is that I build and deploy my project with a CI. Saves me a ton of time.

Thank you for your dedication!


Does this look like a different issue to you? Do you want me to open one?

If it helps in any way, I tried the test project with this version of the firebase plugin. Build went fine.

Have yet to start testing the app.

If it helps in any way, I tried the test project with this version of the firebase plugin. Build went fine.

That version doesn't use cordova-plugin-cocoapod-support so drops support for cordova-ios@4.
However it hard-codes the Firebase SDK version numbers in the podspecs which I'm not keen on doing as it can lead to further version collisions with other plugins.

I may be able to modify cordova-plugin-cocoapod-supportx to be smarter so it only parses plugin variables if using cordova-ios@5 and leaves Cordova to do the actual installation of the pods which I think would resolve the issue.

@dpa99c
I think that is what really happens. Downgrading to 5.0 from 5.0.1 was not a fix but rather a coincidence that i had it temporary fixed. Also my CI is currently failing and I am building from my temporary working dev machine which is a bit unfortunate.

Reopening this as there's an underlying issue that needs fixing

I've published the fix to this as [email protected].
Note the major version increment because it increases the min required versions to cordova@9 CLI and cordova-ios@5 platform due to removal of dependency on cordova-plugin-cocoapod-supportx which was causing this issue.
Plugin variables have been removed for iOS because cordova-ios@5 does not support them for podspecs (whereas cordova-plugin-cocoapod-supportx added bespoke support).

Oh boy oh boy, a successful build!

Next wall, cordova-plugin-googleplus. Great. So, um.. when do you plan to fork it? Or do you handle google auth differently in your apps?

I had an out of date cordova plugin, cordova-plugin-filepicker and updating it fixed this issue for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tux240 picture tux240  路  3Comments

zmoshansky picture zmoshansky  路  6Comments

Akz47 picture Akz47  路  6Comments

almothafar picture almothafar  路  5Comments

marcelonnunes picture marcelonnunes  路  3Comments