最近我决定将GCM集成到已经使用Google Protocol Buffers的项目中。一切都很好,样品还可以。但是当我尝试通过CocoaPods将GCM集成到我的项目中时 - 我开始收到构建错误:
Undefined symbols for architecture x86_64:
"_GSDK_PBLogicalRightShift32", referenced from:
_SerializedSize in libGcmLib.a(GCMSecureSocket.o)
"_OBJC_CLASS_$_GSDK_PBCodedOutputStream", referenced from:
objc-class-ref in libGcmLib.a(GCMSecureSocket.o)
"_OBJC_CLASS_$_GSDK_PBDescriptor", referenced from:
objc-class-ref in libGcmLib.a(GtalkCore.pb.o)
objc-class-ref in libGcmLib.a(GtalkExtensions.pb.o)
"_OBJC_CLASS_$_GSDK_PBGeneratedMessage", referenced from:
_OBJC_CLASS_$_GtalkHeartbeatPing in libGcmLib.a(GtalkCore.pb.o)
_OBJC_CLASS_$_GtalkHeartbeatAck in libGcmLib.a(GtalkCore.pb.o)
_OBJC_CLASS_$_GtalkErrorInfo in libGcmLib.a(GtalkCore.pb.o)
_OBJC_CLASS_$_GtalkSetting in libGcmLib.a(GtalkCore.pb.o)
_OBJC_CLASS_$_GtalkLoginRequest in libGcmLib.a(GtalkCore.pb.o)
_OBJC_CLASS_$_GtalkLoginResponse in libGcmLib.a(GtalkCore.pb.o)
_OBJC_CLASS_$_GtalkClose in libGcmLib.a(GtalkCore.pb.o)
...
"_OBJC_CLASS_$_GSDK_PBRootObject", referenced from:
_OBJC_CLASS_$_GtalkGtalkCoreRoot in libGcmLib.a(GtalkCore.pb.o)
_OBJC_CLASS_$_GtalkGtalkExtensionsRoot in libGcmLib.a(GtalkExtensions.pb.o)
"_OBJC_METACLASS_$_GSDK_PBGeneratedMessage", referenced from:
_OBJC_METACLASS_$_GtalkHeartbeatPing in libGcmLib.a(GtalkCore.pb.o)
_OBJC_METACLASS_$_GtalkHeartbeatAck in libGcmLib.a(GtalkCore.pb.o)
_OBJC_METACLASS_$_GtalkErrorInfo in libGcmLib.a(GtalkCore.pb.o)
_OBJC_METACLASS_$_GtalkSetting in libGcmLib.a(GtalkCore.pb.o)
_OBJC_METACLASS_$_GtalkLoginRequest in libGcmLib.a(GtalkCore.pb.o)
_OBJC_METACLASS_$_GtalkLoginResponse in libGcmLib.a(GtalkCore.pb.o)
_OBJC_METACLASS_$_GtalkClose in libGcmLib.a(GtalkCore.pb.o)
...
"_OBJC_METACLASS_$_GSDK_PBRootObject", referenced from:
_OBJC_METACLASS_$_GtalkGtalkCoreRoot in libGcmLib.a(GtalkCore.pb.o)
_OBJC_METACLASS_$_GtalkGtalkExtensionsRoot in libGcmLib.a(GtalkExtensions.pb.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我认为这是因为GCM库中有ProtocolBuffers,它与我从这里获得的Protobuf源相冲突: https://github.com/google/protobuf/tree/master/objectivec
我也尝试为设备构建并因此收到类似的错误 - 使用armv7而不是x86_64。另外我必须说,该示例项目工作正常,所以我认为Protobuf是这里的主要问题。 不过,我不知道如何解决这个问题。有什么想法吗?
答案 0 :(得分:0)
检查libGcmLib.a
的体系结构和目标构建体系结构是否相同。
您可以使用命令
检查.a
文件的体系结构
otool -hv libGcmLib.a
实际上,跟踪对象不是针对x86_64
架构构建的。
GCMSecureSocket.o
GtalkCore.pb.o
...
如何构建libGcmLib.a
静态库?回顾一下。