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

Use C++ Protobuf in XCode8 IOS app

我正在尝试使用一些使用 Google Protobuf 的现有 C++ 代码在 XCode8 中构建一个 IOS 应用程序,但无法使其正常工作。

我尝试按照 here 和其他地方描述的方式使用 CocoaPods。

还尝试了一些构建脚本:script1, script2

在所有的尝试中我最终得到:

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*)",

还有一些缺少的更多 protobuf 实现函数的列表。

有没有其他方法可以 compile/use IOS 应用程序的 protobuf 库 XCode?

如果您想集成 C++ 代码,您必须将 C++ 代码的文件结尾从 .cpp 更改为 .mm。你这样做了吗?

已解决:我的系统上有多个版本的 protobuf 从所有尝试中,我不小心混合了包含、lib 和 protoc 生成文件的不同版本。