Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libGoogleAnalytics.a linking problems with iPhone iOS4 Simulator

I recently upgraded to the iOS4 SDK and my app no longer compiles for the simulator, but does compile for the device.

This is due to the 3rd party library libGoogleAnalytics.a. The solution seems to be for google to release a new static library complied with the new SDK, unfortunately there is no word of any release date, and due to the new SDK licensing, they may never release a new library.

http://www.google.com/support/forum/p/Google+Analytics/thread?tid=0e35876711dc99b1&hl=en

I am getting the following compile errors:

Undefined symbols:
  ".objc_class_name_NSObject", referenced from:
      .objc_class_name_GANTCPSocket in libGoogleAnalytics.a(GANTCPSocket.o)
      .objc_class_name_GTMLogger in libGoogleAnalytics.a(GTMLogger.o)
      .objc_class_name_GTMLogBasicFormatter in libGoogleAnalytics.a(GTMLogger.o)
      .objc_class_name_GTMLogLevelFilter in libGoogleAnalytics.a(GTMLogger.o)
      .objc_class_name_GTMLogNoFilter in libGoogleAnalytics.a(GTMLogger.o)
      .objc_class_name_GTMLogASLWriter in libGoogleAnalytics.a(GTMLogger+ASL.o)
      .objc_class_name_GTMLoggerASLClient in libGoogleAnalytics.a(GTMLogger+ASL.o)
      .objc_class_name_GANDataDispatcher in libGoogleAnalytics.a(GANDataDispatcher.o)
      .objc_class_name_GANHTTPResponseParser in libGoogleAnalytics.a(GANHTTPResponseParser.o)
      .objc_class_name_GANEvent in libGoogleAnalytics.a(GANEvent.o)
      .objc_class_name_GTMLoggerRingBufferWriter in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      .objc_class_name_GANTracker in libGoogleAnalytics.a(GANTracker.o)
      .objc_class_name_GANPersistentEventStore in libGoogleAnalytics.a(GANPersistentEventStore.o)
  ".objc_class_name_NSFileManager", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSFileManager in libGoogleAnalytics.a(GANPersistentEventStore.o)
  ".objc_class_name_NSString", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSString in libGoogleAnalytics.a(GTMLogger.o)
      literal-pointer@__OBJC@__cls_refs@NSString in libGoogleAnalytics.a(GANTracker.o)
      literal-pointer@__OBJC@__cls_refs@NSString in libGoogleAnalytics.a(GANPersistentEventStore.o)
  ".objc_class_name_NSError", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSError in libGoogleAnalytics.a(GANTracker.o)
      literal-pointer@__OBJC@__cls_refs@NSError in libGoogleAnalytics.a(GANPersistentEventStore.o)
  ".objc_class_name_NSFileHandle", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSFileHandle in libGoogleAnalytics.a(GTMLogger.o)
  ".objc_class_name_NSMutableString", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSMutableString in libGoogleAnalytics.a(GANDataDispatcher.o)
  ".objc_class_name_NSTimer", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSTimer in libGoogleAnalytics.a(GANTracker.o)
  ".objc_class_name_NSMutableArray", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSMutableArray in libGoogleAnalytics.a(GANDataDispatcher.o)
      literal-pointer@__OBJC@__cls_refs@NSMutableArray in libGoogleAnalytics.a(GANPersistentEventStore.o)
  ".objc_class_name_UIScreen", referenced from:
      literal-pointer@__OBJC@__cls_refs@UIScreen in libGoogleAnalytics.a(GANDataDispatcher.o)
  ".objc_class_name_NSProcessInfo", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSProcessInfo in libGoogleAnalytics.a(GTMLogger.o)
  "_objc_exception_extract", referenced from:
      +[GTMLogger sharedLogger] in libGoogleAnalytics.a(GTMLogger.o)
      +[GTMLogger setSharedLogger:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setWriter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setFormatter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setFilter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[NSFileHandle(GTMFileHandleLogWriter) logMessage:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[NSArray(GTMArrayCompositeLogWriter) logMessage:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogStandardFormatter stringForFunc:withFormat:valist:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLoggerRingBufferWriter count] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter droppedLogCount] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter reset] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter dumpContents] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter logMessage:level:] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      +[GANTracker sharedTracker] in libGoogleAnalytics.a(GANTracker.o)
      +[GANTracker allocWithZone:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker startTrackerWithAccountID:dispatchPeriod:delegate:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker trackPageview:withError:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker trackEvent:action:label:value:withError:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker stopTracker] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker dispatch] in libGoogleAnalytics.a(GANTracker.o)
  ".objc_class_name_NSDate", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSDate in libGoogleAnalytics.a(GTMLogger.o)
      literal-pointer@__OBJC@__cls_refs@NSDate in libGoogleAnalytics.a(GANPersistentEventStore.o)
  ".objc_class_name_UIDevice", referenced from:
      literal-pointer@__OBJC@__cls_refs@UIDevice in libGoogleAnalytics.a(GANDataDispatcher.o)
  "_objc_exception_try_exit", referenced from:
      +[GTMLogger sharedLogger] in libGoogleAnalytics.a(GTMLogger.o)
      +[GTMLogger setSharedLogger:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setWriter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setFormatter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setFilter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[NSFileHandle(GTMFileHandleLogWriter) logMessage:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[NSArray(GTMArrayCompositeLogWriter) logMessage:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogStandardFormatter stringForFunc:withFormat:valist:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLoggerRingBufferWriter count] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter droppedLogCount] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter reset] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter dumpContents] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter logMessage:level:] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      +[GANTracker sharedTracker] in libGoogleAnalytics.a(GANTracker.o)
      +[GANTracker allocWithZone:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker startTrackerWithAccountID:dispatchPeriod:delegate:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker trackPageview:withError:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker trackEvent:action:label:value:withError:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker stopTracker] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker dispatch] in libGoogleAnalytics.a(GANTracker.o)
  ".objc_class_name_NSDateFormatter", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSDateFormatter in libGoogleAnalytics.a(GTMLogger.o)
  "_objc_exception_try_enter", referenced from:
      +[GTMLogger sharedLogger] in libGoogleAnalytics.a(GTMLogger.o)
      +[GTMLogger setSharedLogger:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setWriter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setFormatter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogger setFilter:] in libGoogleAnalytics.a(GTMLogger.o)
      -[NSFileHandle(GTMFileHandleLogWriter) logMessage:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[NSArray(GTMArrayCompositeLogWriter) logMessage:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLogStandardFormatter stringForFunc:withFormat:valist:level:] in libGoogleAnalytics.a(GTMLogger.o)
      -[GTMLoggerRingBufferWriter count] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter droppedLogCount] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter reset] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter dumpContents] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      -[GTMLoggerRingBufferWriter logMessage:level:] in libGoogleAnalytics.a(GTMLoggerRingBufferWriter.o)
      +[GANTracker sharedTracker] in libGoogleAnalytics.a(GANTracker.o)
      +[GANTracker allocWithZone:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker startTrackerWithAccountID:dispatchPeriod:delegate:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker trackPageview:withError:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker trackEvent:action:label:value:withError:] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker stopTracker] in libGoogleAnalytics.a(GANTracker.o)
      -[GANTracker dispatch] in libGoogleAnalytics.a(GANTracker.o)
  ".objc_class_name_NSUserDefaults", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSUserDefaults in libGoogleAnalytics.a(GTMLogger.o)
  ".objc_class_name_NSThread", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSThread in libGoogleAnalytics.a(GTMLogger+ASL.o)
  ".objc_class_name_NSBundle", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSBundle in libGoogleAnalytics.a(GANDataDispatcher.o)
  ".objc_class_name_NSAssertionHandler", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSAssertionHandler in libGoogleAnalytics.a(GANTracker.o)
      literal-pointer@__OBJC@__cls_refs@NSAssertionHandler in libGoogleAnalytics.a(GANPersistentEventStore.o)
  ".objc_class_name_NSLocale", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSLocale in libGoogleAnalytics.a(GANDataDispatcher.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

One suggestion on the google forum is to create a dummy implementation of the GANTracker class for use in the simulator. ie to create a file GANTracker_stub.m:

#import "GANTracker.h"

#if TARGET_IPHONE_SIMULATOR

@implementation GANTracker

+ (GANTracker *)sharedTracker
{
    return [[[GANTracker alloc] init] autorelease];
}

- (void)startTrackerWithAccountID:(NSString *)accountID
               dispatchPeriod:(NSInteger)dispatchPeriod
                     delegate:(id<GANTrackerDelegate>)delegate
{
}

- (void)stopTracker
{  
}

- (BOOL)trackPageview:(NSString *)pageURL
        withError:(NSError **)error
{
    return YES;
}

- (BOOL)trackEvent:(NSString *)category
        action:(NSString *)action
         label:(NSString *)label
         value:(NSInteger)value
     withError:(NSError **)error
{
    return YES;
}

- (BOOL)dispatch
{
    return YES;
}

@end
#endif

This however is not working for me, is there something I'm missing?

like image 707
Eamonn Fallon Avatar asked Jun 27 '10 20:06

Eamonn Fallon


2 Answers

Solution found via the Google Analytics forum:

Use:

lipo libGoogleAnalytics.a -remove i386 -output libGoogleAnalytics2.a

Then delete libGoogleAnalytics.a from your project and add libGoogleAnalytics2.a

This only works in conjunction with the dummy implementation of GANTracker as shown above.

like image 144
Eamonn Fallon Avatar answered Nov 18 '22 01:11

Eamonn Fallon


Using Google Analytics for iOS 0.8 SDK would resolve this problem. I just tried today.

Download it from: http://code.google.com/mobile/analytics/download.html

like image 35
Tonny Xu Avatar answered Nov 18 '22 00:11

Tonny Xu