cmackay / google-analytics-plugin

Cordova Google Analytics Plugin for Android & iOS
Apache License 2.0
89 stars 43 forks source link

Xcode 7 BitCode linker error #48

Closed dbroadhurst closed 8 years ago

dbroadhurst commented 9 years ago

I've run into the following linker error in Xcode 7.

com.cmackay.plugins.googleanalytics/libGoogleAnalyticsServices.a(TAGDataProvider.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64

petarov commented 9 years ago

One of several issues cordova devs face now with iOS9 ;)

@cmackay GA v3.13 probably fixes this, although I don't have time to try it at the moment.

cmackay commented 9 years ago

Thanks @dbroadhurst for reporting this. I will take a look at this in more detail this weekend and hopefully get a fix out soon. Thanks @petarov for the suggestion about v3.13. I will take a look at that and see if that resolves the issue.

cmackay commented 9 years ago

I am not seeing this error. Xcode 7 is installed on my system but I don't build within xcode, I use the "cordova build ios" command. It builds successfully without any errors. Please provide more details on how I can reproduce this. Thanks!

dbroadhurst commented 9 years ago

I think the problem happens when you build in Xcode 7 for a real device. Confirmed I can also build with cordova and run on a simulator but you need to build in Xcode to release. Just try building and deploying to a device.

btw - I've seem this issue appear in other plugins with the same pattern of only failing when building to deploy to a real device

cmackay commented 9 years ago

Thanks for the additional info. I tried building in xcode but my environment is not really setup currently for a release build. I don't have a developer certificate. I also tried the approach outlined in this http://stackoverflow.com/questions/24061063/how-can-i-deploy-create-ipa-iphone-app-using-cordova-build-ios-release

but I get the message:

No code signing identities found: No valid signing identities (i.e. certificate and private key pair) were found.

Maybe I can try getting the latest sdk updated and then you can verify if it resolves the issue you are having. I will let you know when I get it upgraded. Thanks!

dbroadhurst commented 9 years ago

I tried the latest SDK but it didn't fix, although I just upgraded the lib so I could have missed a step.

There's a lot of conversation around this being a known issue and people are just waiting for a google fix. It is possible to disable bitcode in the xcode build settings which seems to get through the build and link steps but I'm just not convinced analytics still works or how globally switching off bitcode affects other plugins that require bitcode. I'm going to keep searching and please let me know if there's anything I can do to help test any potential fixes.

petarov commented 9 years ago

I also did a quick test and as @dbroadhurst says the upgrade of GA sadly doesn't fix this. Looks like we are waiting for Google to address this.

As suggested in the iOS devs forums, one needs to disable the bitcode option in the (generated cordova) xcode project. This should fix it. However, it is inconvenient for automated builds. The other option would be to just use xcode6 for now ;)

Also there's some info that bitcode is only mandatory for watchOS apps, but this needs to be confirmed.

cmackay commented 9 years ago

I just woke up and started looking into this more. I see you guys are way ahead of me :) I appreciate all the information. I am tracking the issue you linked @petarov and I will see if maybe I can disable the bitcode option through the plugin config. Not sure If that is possible but it might provide a good work around until an official fix is provided from Google. Let me know if either of you find any additional info and I will do the same. I am wondering if I might be able to use a similar approach from this article to have the plugin set the ENABLE_BITCODE = NO; option. http://ezosaleh.com/adjust-ios-deployment-target-with-cordova-hooks-nodejs I will let you know what I find. Thanks!

cmackay commented 9 years ago

http://stackoverflow.com/questions/30848208/new-warnings-in-ios9

cmackay commented 9 years ago

I guess there is not really much that can be done at this point until the native analytics sdk provides bit code. If anyone is having this issue, It looks like the best thing to do is to set ENABLE_BITCODE to NO as shown in the above stackoverflow post. It looks like watch apps require bitcode so hopefully there will be an SDK release soon so that the updates can integrated with this plugin.

jensljungblad commented 9 years ago

I disabled bitcode but the plugin is not reporting to Analytics anymore. Happened when building with the new Xcode.

jensljungblad commented 9 years ago

I'm not good with Xcode or Obj-C but after placing a few breakpoints it seems it ends up in the send function:

  if (!tracker) {
    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"tracker not initialized"];
  } else {
    [tracker send:params];
    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
  }

And runs the [tracker send:params]; line. Not sure what happens there. I can't seem to step inside that method, and I couldn't find it anywhere in the code.

cmackay commented 9 years ago

tracker send is the native analytics tracker method

https://developers.google.com/analytics/devguides/collection/ios/v3/reference/protocol_g_a_i_tracker-p.html#ae200c9432a91242cf4e1e4917f353c14

jensljungblad commented 9 years ago

So any idea why it's not working anymore? Is it working for anyone with the new Xcode?

ashconnell commented 9 years ago

I just had XCode automatically update itself (i was specifically ignoring it as i don't want to worry about iOS9 yet) and came across this issue too.

I set bitcode to NO and now it builds and runs on a device fine. The other issue i had (and maybe the reason analytics aren't sending for you) is the introduction of transport security, which i fixed by adding NSAllowsArbitraryLoads=true in my plist file.

jensljungblad commented 9 years ago

Tried that and also tried

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

posted here: https://www.google.com/search?sclient=psy-ab&es_sm=91&btnG=Search&q=ns+allows+arbitrary+loads#q=google+analytics+app+transport+security+ios9

No luck. Still nothing being reported unfortunately.

hussfelt commented 8 years ago

Just for reference, this is googles issue on the matter: https://code.google.com/p/analytics-issues/issues/detail?id=671

cmackay commented 8 years ago

Looks like there is a new ios sdk with bitcode. I should have a new release of the plugin in the next day or so.

petarov commented 8 years ago

Pretty cool! Compiles flawlessly now :+1: