I have integrated Google Analytics library to my project.
我已将Google Analytics库集成到我的项目中。
Then I configured the bridging header file and I've added the following headers Google Analytics
然后我配置了桥接头文件,我添加了以下标题Google Analytics
#import "Libraries/GoogleAnalytics/GAI.h"
#import "Libraries/GoogleAnalytics/GAIFields.h"
#import "Libraries/GoogleAnalytics/GAILogger.h"
#import "Libraries/GoogleAnalytics/GAITracker.h"
#import "Libraries/GoogleAnalytics/GAIDictionaryBuilder.h"
The initialization of the library in the AppDelegate.swift compiles and runs correctly. I add the following code to track an event
AppDelegate.swift中的库初始化编译并正确运行。我添加以下代码来跟踪事件
var tracker = GAI.sharedInstance().defaultTracker
tracker.send(GAIDictionaryBuilder.createEventWithCategory(category, action: action, label: label, value: value).build())
When trying to generate the build, the following error occurs
尝试生成生成时,会发生以下错误
Undefined symbols for architecture x86_64:
"_NSOverwriteMergePolicy", referenced from:
-[GAIDataStore contextWithModel:URL:] 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)
"_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_$_NSFetchRequest", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
"_OBJC_CLASS_$_NSManagedObjectContext", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
"_OBJC_CLASS_$_NSManagedObjectModel", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
"_OBJC_CLASS_$_NSPersistentStoreCoordinator", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
"_SCNetworkReachabilityCreateWithName", referenced from:
_kDefaultReachabilityApi in libGoogleAnalyticsServices.a(GAIReachabilityChecker.o)
"_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
_kDefaultReachabilityApi in libGoogleAnalyticsServices.a(GAIReachabilityChecker.o)
"_SCNetworkReachabilitySetCallback", referenced from:
_kDefaultReachabilityApi in libGoogleAnalyticsServices.a(GAIReachabilityChecker.o)
"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
_kDefaultReachabilityApi in libGoogleAnalyticsServices.a(GAIReachabilityChecker.o)
"_deflate", referenced from:
+[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_deflateEnd", referenced from:
+[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_deflateInit2_", referenced from:
+[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_inflate", referenced from:
+[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_inflateEnd", referenced from:
+[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_inflateInit2_", referenced from:
+[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm using Xcode 6 GM and try to compile the application running in the iPhone 5s simulator.
我正在使用Xcode 6 GM并尝试编译在iPhone 5s模拟器中运行的应用程序。
EDIT1:
EDIT1:
Libraries required had already been added
已经添加了所需的库
- CoreData.framework
- CoreData.framework
- SystemConfiguration.framework
- SystemConfiguration.framework
- libz.dylib
- libz.dylib
I have partially solved the error adding in bridging header file the following imports
我已经部分解决了在桥接头文件中添加以下导入的错误
#import <CoreData/CoreData.h>
#import <SystemConfiguration/SystemConfiguration.h>
The error message is reduced to
错误消息减少到
Undefined symbols for architecture x86_64:
"_deflate", referenced from:
+[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_deflateEnd", referenced from:
+[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_deflateInit2_", referenced from:
+[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_inflate", referenced from:
+[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_inflateEnd", referenced from:
+[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_inflateInit2_", referenced from:
+[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
EDIT2:
EDIT2:
Finally I solved the problem.
最后我解决了这个问题。
In Target Settings -> Build Settings -> Linking -> Other Linker Flags add the following flag: -lz
在目标设置 - >构建设置 - >链接 - >其他链接器标志中添加以下标志:-lz
2 个解决方案
#1
2
@Ezequiel Perez : You have to include the targets linked libraries.
@Ezequiel Perez:你必须包括目标链接库。
CoreData.framework SystemConfiguration.framework libz.dylib
Try including this....
尝试包括这个....
#2
1
You have to add all the Objective-C libraries GA needs explicitly.
您必须明确添加GA所需的所有Objective-C库。
In the error output you can see that it is looking for Core Data but instead finds "undefined symbols". That shows you that it is missing the library. Notice that the Objective-C libraries are distinct from the modules you import in Swift.
在错误输出中,您可以看到它正在寻找核心数据,而是找到“未定义的符号”。这表明它缺少了库。请注意,Objective-C库与您在Swift中导入的模块不同。
To solve this, go to build phases of your target and link to the necessary libraries, starting with CoreData.framework
. Consult the GA documentation on which other libraries you need.
要解决这个问题,请从CoreData.framework开始,构建目标阶段并链接到必要的库。请参阅GA文档,了解您需要的其他库。
EDIT:
编辑:
I made a quick app, added GA and made it work by adding the libraries. Maybe you could try removing the libs.dylib library and re-adding it. I also recommend to just include the headers by name
我做了一个快速的应用程序,添加了GA并通过添加库使其工作。也许您可以尝试删除libs.dylib库并重新添加它。我还建议只按名称包含标题
#include "GAI.h"
#1
2
@Ezequiel Perez : You have to include the targets linked libraries.
@Ezequiel Perez:你必须包括目标链接库。
CoreData.framework SystemConfiguration.framework libz.dylib
Try including this....
尝试包括这个....
#2
1
You have to add all the Objective-C libraries GA needs explicitly.
您必须明确添加GA所需的所有Objective-C库。
In the error output you can see that it is looking for Core Data but instead finds "undefined symbols". That shows you that it is missing the library. Notice that the Objective-C libraries are distinct from the modules you import in Swift.
在错误输出中,您可以看到它正在寻找核心数据,而是找到“未定义的符号”。这表明它缺少了库。请注意,Objective-C库与您在Swift中导入的模块不同。
To solve this, go to build phases of your target and link to the necessary libraries, starting with CoreData.framework
. Consult the GA documentation on which other libraries you need.
要解决这个问题,请从CoreData.framework开始,构建目标阶段并链接到必要的库。请参阅GA文档,了解您需要的其他库。
EDIT:
编辑:
I made a quick app, added GA and made it work by adding the libraries. Maybe you could try removing the libs.dylib library and re-adding it. I also recommend to just include the headers by name
我做了一个快速的应用程序,添加了GA并通过添加库使其工作。也许您可以尝试删除libs.dylib库并重新添加它。我还建议只按名称包含标题
#include "GAI.h"