phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Build failing on IOS after adding Push plugin (with one other plugin) #2274

Open viking2917 opened 6 years ago

viking2917 commented 6 years ago

Expected Behaviour

It should be possible to add the Push plugin in combination with the OpenWith Share on IOS plugin (https://github.com/j3k0/cordova-plugin-openwith)

Actual Behaviour

Building with both plugins installed fails.

Reproduce Scenario (including but not limited to)

First add the OpenWith plugin (it introduces a second build target for the ios Share extension). 'ionic cordova build ios' works. Then add the push plugin, and build again, and it fails with what looks like a cocoapods-related error. (The app builds fine if I add just Push, I do have Cocoapods set up correctly I believe). Steps to reproduce below. (Note this is unrelated to the mistake of opening the .proj file instead of the .workspace file - I opened in the workspace file, and in any case this is a command line error.

I don't know definitively that Push is at fault, but as the error seems related to CocoaPods I think it may have to do with the build setup in the situation of multiple targets....

Am I doing something wrong?

Steps to Reproduce

Prior to the steps below, one must set up an App Group in the Apple Developer portal and ensure the app id, the developer cert and app groups all line up. You will get signing errors during compilation if that is not done correctly.

ionic start intentTest7 blank --type ionic1
cd intentTest7
ionic cordova platform add ios
cordova plugin add cc.fovea.cordova.openwith --variable ANDROID_MIME_TYPE="text/*"  --variable IOS_URL_SCHEME=ccfoveaopenwithdemo  --variable IOS_UNIFORM_TYPE_IDENTIFIER=public.text
(open workspace file and assign developer signing certs to both build targets, the app and the Share Extension)
ionic cordova build ios 

-> works

then

ionic cordova plugin add phonegap-plugin-push@2.1.3
ionic cordova build ios

-> fails

(note: before building one must of course open Xcode and set developer Signing certs correctly)

The trouble seems to start with these messages: (the warnings are I think OK - I get them even in projects that build OK)

ld: warning: directory not found for option '-L/Users/markwatkins/Library/Developer/Xcode/DerivedData/intentTest8-cpqwhiyuvrwcipabuudqqtutnakb/Build/Intermediates.noindex/ArchiveIntermediates/intentTest8/BuildProductsPath/Debug-iphoneos/GoogleToolboxForMac'
ld: warning: directory not found for option '-L/Users/markwatkins/Library/Developer/Xcode/DerivedData/intentTest8-cpqwhiyuvrwcipabuudqqtutnakb/Build/Intermediates.noindex/ArchiveIntermediates/intentTest8/BuildProductsPath/Debug-iphoneos/Protobuf'
ld: warning: directory not found for option '-L/Users/markwatkins/Library/Developer/Xcode/DerivedData/intentTest8-cpqwhiyuvrwcipabuudqqtutnakb/Build/Intermediates.noindex/ArchiveIntermediates/intentTest8/BuildProductsPath/Debug-iphoneos/nanopb'
ld: library not found for -lnanopb
clang: error: linker command failed with exit code 1 (use -v to see invocation)

A complete dump of the output/logs is attached. buildfail.txt

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

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Cordova CLI version and cordova platform version

cordova --version                                    # e.g. 6.0.0

8.0

cordova platform version android                     # e.g. 4.1.1

Installed platforms: ios 4.5.4 Available platforms: android ~7.0.0 browser ~5.0.1 osx ~4.0.1 windows ~5.0.0 www ^3.12.0

Plugin version

cordova plugin version | grep phonegap-plugin-push   # e.g. 1.5.3

phonegap-plugin-push 2.2.2 "PushPlugin"

Sample Push Data Payload

Sample Code that illustrates the problem

Logs taken while reproducing problem

macdonst commented 6 years ago

@viking2917 my best guess would be the hooks that the cordova-plugin-openwith executes mess up stuff but I haven't tried to reproduce it yet.

viking2917 commented 6 years ago

Thanks @macdonst. I will take a look tomorrow and chase that angle, see what's up.

Weirdly, this scenario (I've done it many times with slight variations), will often build in Xcode, but not via CLI. Don't have a specific path to repro that but its what seems to happen....

viking2917 commented 6 years ago

OK @macdonst I think this is a case of operator error. When I take the above steps, only after cd intentTest7 I run

sudo gem install cocoapods

It seems to work fine. I had thought my installation of cocoapods was global, but apparently it was not somehow. I'm fine to close this, sorry for the confusion.

viking2917 commented 6 years ago

So, the problem occurred for me again and I think I found the source of the issue. The OpenWith setup either mangles, or doesn't update, the linker flags in the Share Ext target. So it was missing the linker flags to the pods library.

I fixed this by selecting the Share Ext build target, going to 'Build Phases', then hitting + and 'Add Link Binary with Libraries', and added 'libPods-.a ' to the list of libraries (it was the only one, there were none before in the Share Ext).

I know little enough about Xcode to really know whether the Plugin should have added that library to the build phases because the other target was using it, or whether that's on the end developer (e.g. me) to do that. But it might warrant a note in the install guide, if one is using other plugins that require cocoapods.

Hat tip to this SO question for pointing me in the right direction. https://stackoverflow.com/questions/25538579/use-cocoapods-with-an-app-extension

kavithamahe commented 6 years ago

plugin_not_installed error but i already install phonegap push plugin.

jj449 commented 4 years ago

So, the problem occurred for me again and I think I found the source of the issue. The OpenWith setup either mangles, or doesn't update, the linker flags in the Share Ext target. So it was missing the linker flags to the pods library.

I fixed this by selecting the Share Ext build target, going to 'Build Phases', then hitting + and 'Add Link Binary with Libraries', and added 'libPods-.a ' to the list of libraries (it was the only one, there were none before in the Share Ext).

I know little enough about Xcode to really know whether the Plugin should have added that library to the build phases because the other target was using it, or whether that's on the end developer (e.g. me) to do that. But it might warrant a note in the install guide, if one is using other plugins that require cocoapods.

Hat tip to this SO question for pointing me in the right direction. https://stackoverflow.com/questions/25538579/use-cocoapods-with-an-app-extension

thanks for the info , but after following the steps , still no luck . when send picture to my app , still cause push-plugin onRegister event , and share intent not received still. Any one know how to fix this ? Thanks.