简体   繁体   English

在XCode8 IOS应用中使用C ++ Protobuf

[英]Use C++ Protobuf in XCode8 IOS app

I'm trying to build an IOS app in XCode8 with some existing C++ code that uses Google Protobuf, but can't get it to work. 我正在尝试使用一些使用Google Protobuf的现有C ++代码在XCode8中构建IOS应用程序,但无法使其正常工作。

I tried using CocoaPods as described here and in other places. 我尝试按此处和其他地方所述使用CocoaPods。

Also tried some building scripts: script1 , script2 . 还尝试了一些构建脚本: script1script2

In all of the tries I eventually got: 在所有尝试中,我最终得到:

Undefined symbols for architecture arm64: 
  "google_public::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google_public::protobuf::io::CodedOutputStream*)", 
  "google_public::protobuf::internal::WireFormat::VerifyUTF8StringFallback(char const*, int, google_public::protobuf::internal::WireFormat::Operation, char const*)",
  "google_public::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned char*)",

With a list of some more protobuf implementation functions that are missing. 带有一些缺少的protobuf实现功能的列表。

Is there any other way to compile/use the protobuf library XCode for IOS app? 还有其他方法可以编译/使用IOS应用程序的protobuf库XCode吗?

If you want to integrate C++ code you have to change the file ending for the C++ code from .cpp to .mm. 如果要集成C ++代码,则必须将C ++代码结尾的文件从.cpp更改为.mm。 Have you done this? 你做完了吗?

解决:在所有尝试中,我的系统上都有多个版本的protobuf,并且我意外地将include,lib和protoc生成的文件的不同版本混合在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM