Google Analytics(分析)不适用于新的iOS项目

我已经创build了一个新的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

来自Google Analytics 开发者页面

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. 删除CoreData.framework
  2. 再次添加CoreData.framework

现在支持arm64 。 感谢Amar。

现在我应该修正最后的警告:

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

这是因为我在不同用户的项目上工作。

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

为此,在项目目标下,在常规选项卡上,您会看到“链接的框架和库”,只需select“+”button,然后从那里添加框架