How to build a protobuf static library in iOS

931 views
Skip to first unread message

qingq lee

unread,
Feb 22, 2021, 3:36:10 AM2/22/21
to Protocol Buffers
Hello every body,

Is there any official guide to support protobuf c++ in iOS?

I want to build a static library of protobuf in iOS, and load it in xcode project.
my Mac OS is 10.15.6, xcode is 12.4
And I face issue as below:

Case1:
but failed in "make check", 
the issue is -bash: /usr/local/bin/protoc: Bad CPU type in executable

Case2:
Follow the guide of 
and build .a static library success, but there are many issues when load it in xcode project.
Undefined symbols for architecture arm64e:
"google::protobuf::Message::GetTypeName() const", referenced from:

      vtable for securegcm::Ukey2Message in ukey.pb.o

      vtable for securegcm::Ukey2Alert in ukey.pb.o

      vtable for securegcm::Ukey2ClientInit_CipherCommitment in ukey.pb.o

      ...

  "google::protobuf::Message::DiscardUnknownFields()", referenced from:

But when I remove the library from the xcode project, the same issue still exist.
as I check with lipo, the architecture is correct.

Case3:
I use the Cmake to make a xcode project(Cmake + official source code), 
and then change the project setting, from macOS to iOS, 
it work well and generate the static library successfully.
but when load it in xcode, the issue is the same as Case 2.

Can anyone told me how to fix the issue?
Or if anyone can share a correct guide for me to solve it?
Thank you very much:)

Reply all
Reply to author
Forward
0 new messages