Google Analytics不适用于新的iOS项目

Dmi*_*try 21 iphone google-analytics ios

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

我添加到框架:

libGoogleAnalyticsServices.a
AdSupport.framework
CoreData.framework
SystemConfiguration.framework
libz.dylib
Run Code Online (Sandbox Code Playgroud)

但它不适用于错误:

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)
Run Code Online (Sandbox Code Playgroud)

我该如何解决?它支持arm64吗?

Ama*_*mar 46

来自Google Analytics 开发者页面

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

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

看起来你错过了CoreData.framework.


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

xcrun -sdk iphoneos lipo -info libGoogleAnalyticsServices.a
Run Code Online (Sandbox Code Playgroud)

给出结果,

Architectures in the fat file: libGoogleAnalyticsServices.a are: armv7 armv7s i386 x86_64 arm64 
Run Code Online (Sandbox Code Playgroud)

所以它确实支持arm64.

希望有所帮助!


Dmi*_*try 12

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

  1. 删除CoreData.framework.
  2. 再添一次CoreData.framework.

现在支持arm64.感谢Amar.

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

ld: warning: directory not found for option '-L/Users/.../Sources/GoogleAnalytics'
Run Code Online (Sandbox Code Playgroud)

之所以发生这种情况,是因为我与不同用户的项目合作