Problems compiling an iOS 5 application using Google Analytics / GANTracker

When I try to install Google Analytics and compile an iOS 5 project, I get the following error message:

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

and the code will not compile. My build goal is iOS 5, I am linking the following libraries:
- libsqlite3.dylib
- libz.dylib
- libGoogleAnalytics.a
- CFNetwork
- and GANTracker.h

and putting:

 #import "GANTracker.h" #define kGANAccountId @"UA-XXXXXXX-X" static const NSInteger kGANDispatchPeriodSec = 10; @implementation AppDelegate @synthesize window = _window; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[GANTracker sharedTracker] startTrackerWithAccountID:kGANAccountId dispatchPeriod:kGANDispatchPeriodSec delegate:nil]; NSError *error; if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1 name:@"iPhone1" value:@"iv1" withError:&error]) { // Handle error here } if (![[GANTracker sharedTracker] trackEvent:@"my_category" action:@"my_action" label:@"my_label" value:-1 withError:&error]) { // Handle error here } if (![[GANTracker sharedTracker] trackPageview:@"/app_entry_point" withError:&error]) { // Handle error here } 

Anything I've been following everything: http://code.google.com/mobile/articles/analytics_end_to_end.html

Am I missing a library or framework? I am using Xcode version 4.3.1

+4
source share
4 answers

If you are still wondering what caused your problem, most likely your libGoogleAnalytics library will only be compiled for one architecture (ARM), not i386 (for the simulator).

So, how can you determine which architectures are part of binary code? To do this, you can use otool , for example. the following command (on the terminal):

otool libGoogleAnalytics.a -f

It gives me the following result (note: I myself created a live Google Analytics binary library):

 Fat headers fat_magic 0xcafebabe nfat_arch 3 architecture 0 cputype 7 cpusubtype 3 capabilities 0x0 offset 68 size 243208 align 2^2 (4) architecture 1 cputype 12 cpusubtype 6 capabilities 0x0 offset 243276 size 231504 align 2^2 (4) architecture 2 cputype 12 cpusubtype 9 capabilities 0x0 offset 474780 size 229552 align 2^2 (4) Archive : libGoogleAnalytics.a (architecture i386) Archive : libGoogleAnalytics.a (architecture armv6) Archive : libGoogleAnalytics.a (architecture armv7) 

The last 3 lines show the supported architectures. You can create your own bold binaries using the lipo command line tool.

+3
source

If GARTracker is missing from your compilation sources? Go to your project settings, then specify the purpose of the application assembly, then the assembly phases and make sure that all your dependencies are present in the appropriate sections.

build phases image

0
source

I had the same problem and it was solved by adding everything you added, and also added libGoogleAnalytics_NoThumb.a, which you did not talk about. I found it here:

http://code.google.com/apis/analytics/docs/mobile/download.html

0
source

Just make sure CFNetwork.framework is listed in the Linking Binary Files to Libraries section. In your current target "Build Phases".

This solved my problem.

0
source

Source: https://habr.com/ru/post/1403733/


All Articles