urbanairship / urbanairship-cordova

Urban Airship integration with Apache Cordova
https://docs.airship.com/platform/mobile/setup/sdk/cordova/
Other
142 stars 149 forks source link

Cannot build using UrbanAirship 6.3.0 on Xcode 8 for Cordova #164

Closed rwillett closed 7 years ago

rwillett commented 7 years ago

Hi,

We're testing out our app to see if Urban Airship is the right solution for us. We seem to have stumbled at the first hurdle in that we can' t get our app to compile. Just to put some context, we have a production app thats been in the Apple App store for months so we have a working workflow using another notification provider

We followed the guide at

http://docs.urbanairship.com/platform/phonegap.html#getting-started

We then downloaded all the CocaPods stuff and got that working (or we think we have).

We then tried to compile and had this error message.

ld: warning: directory not found for option '-L/Users/XXXXXX/Library/Developer/Xcode/DerivedData/Jambuster-cmfogaxzhfoatwfrmwanlvsmvfwd/Build/Products/Debug-iphoneos/UrbanAirship-iOS-SDK'
ld: library not found for -lUrbanAirship-iOS-SDK
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looking through this repository we found issue #163 which seemed to match our problem. Based on this issue #163 we cd'ed to platforms/ios and did

pod install

which gave us this message

Robs-MacBook-Pro:ios XXXXX$ pod install
Analyzing dependencies
Downloading dependencies
Using UrbanAirship-iOS-SDK (8.0.4)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

Unclear if there is a problem here or not :)

We then did

cordova build ios

followed by trying to run this in Xcode where we get the same linker error message.

We're a little stuck as we've not had to do this with other plugin software. We also have never used CocaPods so we're having to learn that as well .

We have cleaned out the build folders, started and stopped Xcode (I'm embarrassed to admit that).

We're running

cordova -v
6.4.0

On Ionic 1 and urbanairship-cordova 6.3.0 "Urban Airship"

We can see the following from the root cordova folder

find . -name UrbanAirship-iOS-SDK
./platforms/ios/Pods/Headers/Private/UrbanAirship-iOS-SDK
./platforms/ios/Pods/Headers/Public/UrbanAirship-iOS-SDK
./platforms/ios/Pods/Target Support Files/UrbanAirship-iOS-SDK
./platforms/ios/Pods/UrbanAirship-iOS-SDK

Apologies if there is a simple solution but we can't find it :(

Thanks

Rob

rlepinski commented 7 years ago

Cordova has native support for cocoapods. You should have to manually install the SDK, only add it like you normally do. Make sure you have the latest Cordova CLI, Cordova iOS, and pod installed. I would also recommend clearing your derived data folder.

Is this an upgrade from an older versio of our plugin? If so, it's possible Cordova might of left some older files around. You could try recreating the iOS project if you did not do any major modifications to it.

rlepinski commented 7 years ago

You will also need to open the generated xcworkspace instead of the xcproject when trying to build it directly in xcode.

rwillett commented 7 years ago

@rlepinski

Thanks for the replies.

When you say manually install the SDK do you mean follow the instructions for installing the IOS Urban Airship SDK rather than the Cordova SDK. i.e. the instructions at http://docs.urbanairship.com/platform/ios.html#getting-started

We installed the Urban Airship plugin by doing what we would expect to normally do,cordova plugins add <plugin name>

I'll check that we have the latest Cordova versions, we're normally pretty up to date with these, we certainly have the latest CocoaPod as we installed that purely to try and get the urban Airship Plugin installed.

We've never installed Urban Airship before. We currently use another commercial notification plugin and was interested in seeing if Urban Airship was a better option for us.

We'll recreate the derived data folder as well as opening the generated xcworkspace rather than the xcproject as well and report back.

Thanks

Rob

rwillett commented 7 years ago

Houston, we no longer have a problem :)

We have now got this to compile, so thanks very much for this. I'll log what we did so other people can see and possibly benefit.

  1. We installed CocoaPods as per the CocoaPods website.

  2. We cd'ed to the platforms/IOS directory in our cordova project and did pod install

This is the point at which we had the error

ld: warning: directory not found for option '-L/Users/XXXXXX/Library/Developer/Xcode/DerivedData/Jambuster-cmfogaxzhfoatwfrmwanlvsmvfwd/Build/Products/Debug-iphoneos/UrbanAirship-iOS-SDK'
ld: library not found for -lUrbanAirship-iOS-SDK
clang: error: linker command failed with exit code 1 (use -v to see invocation)

We then started working through the suggestions you made:

  1. We deleted the DataDerived folder and tried again. Same error.

  2. We started the project up using xcworkspace and that resolved the problem. BINGO!

Our project now starts up, Urban Airship produces a massive amount of debugging information, which is fine at this stage.

We now have to work through all the differences between Urban Airship and our current notification provider and see how it differs.

Thanks for your help

Rob

rlepinski commented 7 years ago

@rwillett Cordova has support for cocaopods, so ideally you would not have to run pod install manually, instead running cordova build ios should do that for you.

We will update the readme with a note that we use cocapods now and what differences that entails.

rwillett commented 7 years ago

Thanks for the update.

After looking at our log trail it's entirely possible that all we needed to do was open the project workspace and the previous work was wholly redundant.

We may have to do a complete rebuild shortly so well have a look then.

Thanks again for the help.

Rob

rlepinski commented 7 years ago

The other thing you pointed out is the logging for the UA SDK is very verbose. The SDK supports different log levels, but the cordova plugin sets it to DEBUG for debug builds, and ERROR for release builds. If its an issue for you we can expose a way to set the log level in the plugin.

rwillett commented 7 years ago

Yes, it is very verbose.

We have a working app, we have got the server API working and can send notifications to the app quite easily now.

We're still exploring how UA works in comparison to other notification providers though. We have been using a different provider for the last year and thats been working pretty well. Their model of notifications is quite different to yours, so we're trying to understand those differences and whether they are good, bad or we can ignore them.

At the moment we'd prefer to cut the logging down as we work through evaluating UA, so if there is an easy way that'd be great.

Rob

rlepinski commented 7 years ago

The plugin is setting the log levels directly, so its going to require a code change. We can have something out this week to address the issue.

rlepinski commented 7 years ago

Actually you can probably modify the UAirshipPlugin.m directly in the generated project. Remove these 2 lines and it will reduce the logs - https://github.com/urbanairship/phonegap-ua-push/blob/master/src/ios/UAirshipPlugin.m#L85 or you can set them to a higher level like INFO.

It looks like they are currently set to trace instead of the default values.

rwillett commented 7 years ago

Ok, thanks we'll do that. We're finishing off some other code so will be a day or so before we get back to this.

Best wishes,

Rob

rlepinski commented 7 years ago

@rwillett We released 6.4.0 with configurable log levels. We are also no longer setting all log levels to trace, so by just updating to 6.4.0 logging should be significantly better.