Google Analytics不适用于新的iOS项目

时间:2014-02-25 08:48:30

标签: ios iphone google-analytics

我已经创建了一个新的iOS项目,并根据官方说明添加了Google Analytics支持。

我已添加到框架:

libGoogleAnalyticsServices.a
AdSupport.framework
CoreData.framework
SystemConfiguration.framework
libz.dylib

但它不适用于错误:

ld: warning: directory not found for option '-L/Users/.../Sources/GoogleAnalytics'
Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_NSManagedObjectModel", referenced from:
      objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
  "_OBJC_CLASS_$_NSAttributeDescription", referenced from:
      objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
  "_OBJC_CLASS_$_NSEntityDescription", referenced from:
      objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
      objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
  "_OBJC_CLASS_$_NSPersistentStoreCoordinator", referenced from:
      objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
  "_OBJC_CLASS_$_NSFetchRequest", referenced from:
      objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
  "_OBJC_CLASS_$_NSManagedObjectContext", referenced from:
      objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
  "_NSSQLiteErrorDomain", referenced from:
      -[GAIDataStore performBlockAndWait:withError:] in libGoogleAnalyticsServices.a(GAIDataStore.o)
  "_NSSQLiteStoreType", referenced from:
      -[GAIDataStore coordinatorWithModel:URL:] in libGoogleAnalyticsServices.a(GAIDataStore.o)
  "_NSOverwriteMergePolicy", referenced from:
      -[GAIDataStore contextWithModel:URL:] in libGoogleAnalyticsServices.a(GAIDataStore.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我该如何解决?它是否支持 arm64

3 个答案:

答案 0 :(得分:46)

来自Google Analytics developer page

  

Google AnalyticsSDK使用CoreData和SystemConfiguration框架,因此您需要将以下内容添加到应用程序目标的链接库中:

     
      
  • libGoogleAnalyticsServices.a
  •   
  • AdSupport.framework程式
  •   
  • CoreData.framework
  •   
  • SystemConfiguration.framework
  •   
  • libz.dylib
  •   

看起来你错过了CoreData.framework


在GA库上运行lipo -info命令。

xcrun -sdk iphoneos lipo -info libGoogleAnalyticsServices.a

给出结果,

Architectures in the fat file: libGoogleAnalyticsServices.a are: armv7 armv7s i386 x86_64 arm64 

所以它确实支持arm64。

希望有所帮助!

答案 1 :(得分:12)

谢谢大家!以下步骤对我有所帮助:

  1. 删除CoreData.framework
  2. 再次添加CoreData.framework
  3. 现在支持

    arm64 。感谢Amar。

    现在我应该修复最后一个警告:

    ld: warning: directory not found for option '-L/Users/.../Sources/GoogleAnalytics'
    

    这是因为我在不同的用户上使用该项目。

答案 2 :(得分:4)

您应该将libsqlite3.0.dylib文件添加到框架中。

为此,在项目目标下,在常规选项卡上,您将找到"链接的框架和库",只需选择' +'按钮,并从那里添加框架