Unable to link GoogleAnalytics 3.01 with XCode 5 (

2019-01-16 12:32发布

I have built my App (targeted for iOS7) and now want to apply Google Analytics as the last step before submission. What I did:

  1. Downloaded GA for iOS 3.01
  2. Imported content of /GoogleAnalytics/Library/ into group "GoogleAnalytics"
  3. Imported libGoogleAnalyticsServices.a into group "GoogleAnalytics"
  4. Added Build Phases and swapped build phase libGoogleAnalytics_debug.a with libGoogleAnalyticsServices.a
  5. Added code block #include "GAI.h" to my -Prefix.pch-file.
  6. Initialize the [GAI sharedInstance] in my AppDelegate.

I have attached screenshots of the setup in the bottom of this post. When I try to build (either device or simulator, both 32bit), I get the following linker errors:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_GAI", referenced from:
      objc-class-ref in FTVAppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How do I solve this?

UPDATE 1

I also get the warning

ld: warning: ignoring file .../libGoogleAnalyticsServices.a, missing required architecture x86_64 in file .../libGoogleAnalyticsServices.a (3 slices)
ld: warning: ignoring file .../SDWebImage.framework/SDWebImage, missing required architecture x86_64 in file .../SDWebImage.framework/SDWebImage (3 slices)

UPDATE 2

This error only occurs when building for 64bit. I had accidentally set "Build Only for active architectures" to NO, when this changed to YES, I was able to build yet again. This means that the App now does NOT work on iPhone 5S - which is still a problem.

4条回答
兄弟一词,经得起流年.
2楼-- · 2019-01-16 12:41

Good news everyone, fixed by the 3.03 release:

64-bit support is now available in v3.03 of the Google Analytics Services SDK for iOS. (Source)

查看更多
仙女界的扛把子
3楼-- · 2019-01-16 12:43

You're not doing anything wrong. I'm pretty sure google has not yet provided a arm64 version of their libGoogleAnalyticsServices.a, which is really annoying ...it has been weeks since the public the release of Xcode 5GM.

For now, I guess only build for armv7, armv7s or remove google analytics until they get their head out of their pants.

UDATE: Finally fixed https://developers.google.com/analytics/devguides/collection/ios/resources

查看更多
Emotional °昔
4楼-- · 2019-01-16 12:55

I see on first screenshot that your project has 2 targets. Are you sure that libGoogleAnalyticsServices.a added to both targets? Linked frameworks may differ from target to target, so it's most common error this way... Also try remove GA from project, then Clean, then Clean Build Folder, then restart Xcode and add GA again =) Yesterday this helped me =)

查看更多
地球回转人心会变
5楼-- · 2019-01-16 12:56

Select this option in the Architecture section in "Build Settings" and your code will run on iPhone 5S, I had the same trouble.

Build Settings

查看更多
登录 后发表回答