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

iOS builds fail if first build is from CLI #22

Closed
Birowsky opened this issue Jun 30, 2019 · 31 comments
Closed

iOS builds fail if first build is from CLI #22

Birowsky opened this issue Jun 30, 2019 · 31 comments
Labels
bug Something isn't working properly investigate Issue requires investigation

Comments

@Birowsky
Copy link
Sponsor

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

@Birowsky
Copy link
Sponsor Author

Some extra info:

When running cordova platform add ios@5.0.1 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.

@yosikal
Copy link

yosikal commented Jun 30, 2019

Same here

@dpa99c
Copy link
Owner

dpa99c commented Jun 30, 2019

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.

@Birowsky
Copy link
Sponsor Author

@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

@dpa99c
Copy link
Owner

dpa99c commented Jun 30, 2019

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

@dpa99c dpa99c added the help wanted Collaboration wanted on this issue label Jun 30, 2019
@Birowsky
Copy link
Sponsor Author

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?

@dpa99c
Copy link
Owner

dpa99c commented Jun 30, 2019

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

@yosikal
Copy link

yosikal commented Jul 1, 2019

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

@dpa99c dpa99c closed this as completed Jul 1, 2019
@Birowsky
Copy link
Sponsor Author

Birowsky commented Jul 1, 2019

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

I don't wanna be modifying uncommitable sources.

@dpa99c
Copy link
Owner

dpa99c commented Jul 1, 2019

@Birowsky I've captured this as #25

@Birowsky
Copy link
Sponsor Author

Birowsky commented Jul 1, 2019

@dpa99c awesomeness.

@dpa99c
Copy link
Owner

dpa99c commented Jul 1, 2019

Just published cordova-plugin-firebasex@3.0.7 which contains a fix to ensure $(inherited) is always present in the search path. Please give it a try.

@Birowsky
Copy link
Sponsor Author

Birowsky commented Jul 1, 2019

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

@dpa99c
Copy link
Owner

dpa99c commented Jul 1, 2019

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

@AMerkuri
Copy link

AMerkuri commented Jul 1, 2019

I have same problem (3.0.7)

    "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",

  },

@dpa99c
Copy link
Owner

dpa99c commented Jul 1, 2019

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

@AMerkuri
Copy link

AMerkuri commented Jul 1, 2019

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

@Birowsky
Copy link
Sponsor Author

Birowsky commented Jul 1, 2019

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

yosikal commented Jul 2, 2019

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

@AMerkuri
Copy link

AMerkuri commented Jul 2, 2019

@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

@dpa99c
Copy link
Owner

dpa99c commented Jul 2, 2019

@Birowsky I didn't notice your project name contained non-latin characters - this is a known issue with Xcode/Cocoapods - see #18.
Any reason you can't make the project name in latin?

@AMerkuri maybe a bug in cordova-ios@5.0.1?

@yosikal this should be done by default now: 2d86a26

@Birowsky
Copy link
Sponsor Author

Birowsky commented Jul 8, 2019

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?

@dpa99c
Copy link
Owner

dpa99c commented Jul 8, 2019

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: blakgeek/cordova-plugin-cocoapods-support#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.
cordova-ios@5.0.0 adds implicit support for Cocoapods and I've been testing with cordova-ios@5.0.1 but I don't think I can remove the dependency on cordova-plugin-cocoapod-supportx for cordova-ios@5.x 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.

@Birowsky
Copy link
Sponsor Author

Birowsky commented Jul 8, 2019

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?

@Birowsky
Copy link
Sponsor Author

Birowsky commented Jul 8, 2019

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.

@dpa99c
Copy link
Owner

dpa99c commented Jul 8, 2019

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.

@AMerkuri
Copy link

AMerkuri commented Jul 8, 2019

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

@dpa99c
Copy link
Owner

dpa99c commented Jul 8, 2019

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

@dpa99c dpa99c reopened this Jul 8, 2019
@dpa99c dpa99c added bug Something isn't working properly investigate Issue requires investigation and removed help wanted Collaboration wanted on this issue labels Jul 8, 2019
@dpa99c dpa99c changed the title ios crashes from cli / doesn't build from xcode iOS builds fail if first build is from CLI Jul 8, 2019
@dpa99c dpa99c closed this as completed in ec66a5b Jul 8, 2019
@dpa99c
Copy link
Owner

dpa99c commented Jul 8, 2019

I've published the fix to this as cordova-plugin-firebasex@4.0.0.
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).

@Birowsky
Copy link
Sponsor Author

Birowsky commented Jul 9, 2019

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?

@dpa99c dpa99c mentioned this issue Aug 16, 2019
@owen2
Copy link

owen2 commented Nov 13, 2019

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

tommy-hartz pushed a commit to tommy-hartz/cordova-plugin-firebasex that referenced this issue Nov 22, 2019
…ies.

Instead set min supported versions to cordova@9 and cordova-ios@5 and update plugin.xml to use podspec formatting as required by cordova-ios@5.
Remove iOS plugin variables as these are not (currently) supported by cordova-ios@5
Resolves dpa99c#22.
tommy-hartz pushed a commit to tommy-hartz/cordova-plugin-firebasex that referenced this issue Nov 22, 2019
…ependencies. Instead set min supported versions to cordova@9 and cordova-ios@5 and update plugin.xml to use podspec formatting as required by cordova-ios@5. Remove iOS plugin variables as these are not (currently) supported by cordova-ios@5 Resolves dpa99c#22."

This reverts commit ec66a5b.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working properly investigate Issue requires investigation
Projects
None yet
Development

No branches or pull requests

5 participants