Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

[iOS FCM] Library -lGoogleToolboxForMac not found on Xcode build #1737

Closed
kukikiloke opened this issue May 24, 2017 · 28 comments
Closed

[iOS FCM] Library -lGoogleToolboxForMac not found on Xcode build #1737

kukikiloke opened this issue May 24, 2017 · 28 comments

Comments

@kukikiloke
Copy link

Expected Behaviour

Actual Behaviour

Xcode failed to build due to error

ld: warning: directory not found for option '-L/Users/yingweiloke/Library/Developer/Xcode/DerivedData/TeamRN-greqqswbqeruppgwymcpsslcmaxe/Build/Products/Debug-iphoneos/GoogleToolboxForMac'
ld: warning: directory not found for option '-L/Users/yingweiloke/Library/Developer/Xcode/DerivedData/TeamRN-greqqswbqeruppgwymcpsslcmaxe/Build/Products/Debug-iphoneos/Protobuf'
ld: library not found for -lGoogleToolboxForMac
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reproduce Scenario (including but not limited to)

Install the plugin v2.0.0 and build and run the project with cordova cli. App built and run.
Open the .xcodeproj file on Xcode and build -> failed.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

iOS 10.3.1

Cordova CLI version and cordova platform version

cordova --version 6.5.0
cordova platform version ios 4.4.0

Plugin version

2.0.0-rc3

@shazron
Copy link
Member

shazron commented May 24, 2017

Fixed in #1715

@shazron shazron closed this as completed May 24, 2017
@kukikiloke
Copy link
Author

kukikiloke commented May 24, 2017

I installed the plugin with this commit but I'm still seeing the same issue

@shazron
Copy link
Member

shazron commented May 24, 2017

It definitely works -- did you grab the plugin from the 2.0.x branch?
cordova plugin add https://github.com/phonegap/phonegap-plugin-push.git#v2.0.x

@kukikiloke
Copy link
Author

I did cordova plugin add https://github.com/phonegap/phonegap-plugin-push#e5739b8721eb7210a333725089fec3b36db5b348 and I confirmed that the line <framework src="GoogleToolboxForMac" type="podspec" spec="~> 2.1.1"/> is in the plugin.xml

@shazron
Copy link
Member

shazron commented May 24, 2017

Let me try it out using your method. Will let you know.

@shazron
Copy link
Member

shazron commented May 24, 2017

Using your plugin sha hash, I was able to build successfully. Repro steps:

$ cordova create gtm-test
Creating a new cordova project.
$ cd gtm-test
$ cordova platform add ios
Using cordova-fetch for cordova-ios@~4.4.0
Adding ios project...
Creating Cordova project for the iOS platform:
	Path: platforms/ios
	Package: io.cordova.hellocordova
	Name: HelloCordova
iOS project created with cordova-ios@4.4.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Installing "cordova-plugin-whitelist" for ios
Adding cordova-plugin-whitelist to package.json
Saved plugin info for "cordova-plugin-whitelist" to config.xml
--save flag or autosave detected
Saving ios@~4.4.0 into config.xml file ...
$ cordova plugin add https://github.com/phonegap/phonegap-plugin-push\#e5739b8721eb7210a333725089fec3b36db5b348
Installing "phonegap-plugin-push" for ios
Adding phonegap-plugin-push to package.json
Saved plugin info for "phonegap-plugin-push" to config.xml
$ open platforms/ios/Podfile
$ open -a Xcode platforms/ios
$ cordova --version
7.0.1
$ cordova platform ls
Installed platforms:
  ios 4.4.0
Available platforms:
  android ~6.2.2
  blackberry10 ~3.8.0 (deprecated)
  browser ~4.1.0
  osx ~4.0.1
  webos ~3.7.0
$ xcodebuild -version
Xcode 8.3.2
Build version 8E2002

From above, I opened up the Podfile to verify GTM was there, and I built the project in Xcode 8.3.2 (after setting the correct provisioning profile, cert, etc). It built with no errors.

@kukikiloke
Copy link
Author

Ok, I found out the problem. I had been opening the project on Xcode by platforms/ios/my-app.xcodeproj instead of opening the platforms/ios directory. It was working until the pods thing created as a Xcode project in v2.x.x.

Thanks for your help and the steps to repro!

@shazron
Copy link
Member

shazron commented May 24, 2017

Great! you're welcome :)

@Suffren
Copy link

Suffren commented Jun 29, 2017

The issue persists on a fresh clone of a project that uses this plug-in. (v2.0.0-rc5)
When using ionic cordova build ios --confirm on a fresh clone of the project (it runs npm install then cordova platform add ios then cordova build ios), I get the same errors. (plus GoogleService-Info.plist missing)
It's possible to work around the build issue by running:

ionic cordova plugin remove phonegap-plugin-push
ionic cordova plugin add phonegap-plugin-push@latest

@arthur-tam
Copy link

seems it is not related to the plugin version, but need the action of plugin remove and add
as it ok for
ionic cordova plugin remove phonegap-plugin-push
ionic cordova plugin add phonegap-plugin-push@2.0.0-rc5
but will fail if just edit config.xml for the plugin

@F1LT3R
Copy link

F1LT3R commented Jan 18, 2018

I get this error too. (ld: library not found for -lGoogleToolboxForMac) "Build Failed"

This is a fresh project as of yesterday. I am using phonegap-plugin-push@latest

I am not using GCM of FCM in my project at all. Why would it even try to link these?

@jcesarmobile
Copy link
Collaborator

because the plugin also supports FCM for iOS and we haven't find a way of conditionally add FCM only if you want to use it

@F1LT3R
Copy link

F1LT3R commented Jan 18, 2018

Thanks, @jcesarmobile. Can I pull FCM out after install so Xcode does not try to link it?

@jcesarmobile
Copy link
Collaborator

I don't think the app will be able to build if you remove Firebase as PushPlugin.m has a few imports for it.

@F1LT3R
Copy link

F1LT3R commented Jan 18, 2018

Hmmm... so what are my options if I don't want to use Firebase?

@F1LT3R
Copy link

F1LT3R commented Jan 18, 2018

@macdonst was telling me that I had the option not to use Firebase: #2149

@jcesarmobile
Copy link
Collaborator

You don't have to use it, but you can't get rid of the firebase code.
If you don't add the Firebase configuration plist it won't use firebase, it will use regular APNs, if you add it because another plugin requires it, I think you can still disable it by changing something in the config plist.
But you need CocoaPods to install the plugin, CocoaPods is a native dependency manager that was integrated with Cordova some time ago. Your error message is related to not having CocoaPods installed or failing to install the Firebase dependency for some reason.

@F1LT3R
Copy link

F1LT3R commented Jan 18, 2018

Ok thanks, I do have Cocoapods installed. I suppose I will try installing the Google toolbox and see if that helps.

@jcesarmobile
Copy link
Collaborator

Try navigating to projectName/platforms/ios/ and run pod install there, it should install firebase correctly or tell you more about what is failing.

@F1LT3R
Copy link

F1LT3R commented Jan 18, 2018

Thanks, @jcesarmobile I will try that now.

Sidenote: I think I just noticed this workaround in the docs, so apologies if I am wasting your time on this. (I missed it before thinking I did not have to take any Firebase instructions into account):

--- BEGIN QUOTE ---

Library not found for -lGoogleToolboxForMac

Trying to build for iOS using the latest cocoapods (1.2.1) but failed with the following error (from terminal running cordova build ios):

ld: library not found for -lGoogleToolboxForMac

--- END QUOTE ---

Builds Pass in Shell

I do want to point out something quote interesting: builds pass when run from the shell, but fail when building from Xcode.

 cordova build ios

# --- OUTPUT ---
# Non-system Ruby in use. This may cause packaging to fail.
# If you use RVM, please run `rvm use system`.
# If you use chruby, please run `chruby system`.
# 2018-01-18 12:50:48.939 xcodebuild[30860:2159529] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/kw/5t8w91_n6rb0z8b2z2grsj1r0000gn/T/RemotePushNotificationsApp_2018-01-18_12-50-48.938.xcdistributionlogs'.
# Exported RemotePushNotificationsApp.xcarchive to: /Users/...
# ** EXPORT SUCCEEDED **

In this case, the app runs fine on my device with cordova run ios, and I do receive the Push Notifications through Amazon SNS.

img_0015

@F1LT3R
Copy link

F1LT3R commented Jan 18, 2018

cd platforms/ios/
pod install

# Analyzing dependencies
# Downloading dependencies
# Using FirebaseAnalytics (4.0.5)
# Using FirebaseCore (4.0.13)
# Using FirebaseInstanceID (2.0.8)
# Using FirebaseMessaging (2.0.8)
# Using GoogleToolboxForMac (2.1.3)
# Using Protobuf (3.5.0)
# Using nanopb (0.3.8)
# Generating Pods project
# Integrating client project
# Sending stats
# Pod installation complete! There is 1 dependency from the Podfile and 7 total # pods installed.

Build still fails in Xcode.

screen shot 2018-01-18 at 1 00 21 pm

@jcesarmobile
Copy link
Collaborator

Are you opening the .xcodeproj or the .xcworkspcae?

@F1LT3R
Copy link

F1LT3R commented Jan 18, 2018

Ah! I was opening the .xcodeproj but when I open the .xcodeworkspace the build passes.

Thank you for versing a noob. Much appreciated.

@samuelsc
Copy link

samuelsc commented Feb 1, 2018

Thanks for all your help. This issue should be documented in Installation guide as well.

@johnye2e
Copy link

johnye2e commented Apr 11, 2018

This issue is still reproducible on 2.2.2. I had to run pod install manually.

@jcesarmobile
Copy link
Collaborator

This is a Cordova plugin, pod install seems to fail or some files are missing.
Manually going to platforms/ios and running pod install there fixes the issue

@skaman
Copy link

skaman commented Apr 12, 2018

Because I can't run it manually (must compile with fastlane on our CD server) i worked around adding a custom hook:

Add a file scripts/pod_install.js:

const { exec } = require('child_process');

module.exports = function(context) {
    console.log("Running pod install");
    exec('cd ' + context.opts.projectRoot + '/platforms/ios && pod install');
    console.log("Done");
}

Then add this line inside config.xml (under the iOS platform):
<hook src="scripts/pod_install.js" type="after_plugin_install" />

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

9 participants