Protobuf on iOS

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Protobuf on iOS

Robert Bielik-4
Hi all,

CMake version: 3.9.4

Trying to build protobuf on iOS via the toolchains @ https://github.com/ruslo/polly (ios-10-2.cmake). With some additional tricks in my wrapper CMakeLists file:

 if (IOS)
    set(CMAKE_MACOSX_BUNDLE OFF)
    find_package(Threads REQUIRED)
endif ()
add_subdirectory(protobuf/cmake)

it works fine up til the point where protoc is compiled. CMake files are generated like so:

cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/polly/ios-10-2.cmake <path to my protobuf wrapper>

The error produced is:

target specifies product type 'com.apple.product-type.tool', but there's no such product type for the 'iphoneos' platform

Granted, I won't really need the protoc target during cross building, but I'd rather stay clear of the CMake files of protobuf.

Ideas ?

TIA
/Robert

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Protobuf on iOS

Craig Scott-3
As a starting point, you can try this as your toolchain file rather than the one from polly if you want to pare things down to help investigate what's going on:

set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO)
set(CMAKE_OSX_SYSROOT iphoneos)

This should be the minimal required toolchain with a reasonably recent Xcode. Note that this doesn't set any search paths for the various find_...() commands, if that matters to you, but it should get you past the try_compile() stage in the first project() command (which I think is where you're getting your error message from). It will also allow you to switch between device and simulator builds at build time (Xcode handles that for you, even though you only specified iphoneos as the sysroot). You can also choose the architecture at build time too.

What you need to do after that in terms of setting up code signing depends on what Xcode version you're using and whether you want to use automatic signing and provisioning or whether you want full manual control. For more info than you probably care about for this last point, a detailed write-up can be found here (not specific to CMake though):


If you're happy using Xcode 8 or later and automatic signing/provisioning, you only need to set two things (three if you want to specify the deployment target, which you probably do). Put something like this after the first project() command:

set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 10.0)
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM xxxxxxxxxx CACHE STRING "")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer" CACHE STRING "")

Replace xxxxxxxxxx with your development team ID. Even for distribution builds, you want the code signing identity set to "iPhone Developer" - see the above code signing link for the reasons why. Chances are your project wants a specific deployment target, but developers may have a need to override the development team ID and/or the signing identity in certain circumstances, hence why these two have been defined as cache variables in the above example but the deployment target hasn't.

See if that enables you to make some progress.



On Tue, Oct 17, 2017 at 8:12 PM, Robert Bielik <[hidden email]> wrote:
Hi all,

CMake version: 3.9.4

Trying to build protobuf on iOS via the toolchains @ https://github.com/ruslo/polly (ios-10-2.cmake). With some additional tricks in my wrapper CMakeLists file:

 if (IOS)
    set(CMAKE_MACOSX_BUNDLE OFF)
    find_package(Threads REQUIRED)
endif ()
add_subdirectory(protobuf/cmake)

it works fine up til the point where protoc is compiled. CMake files are generated like so:

cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/polly/ios-10-2.cmake <path to my protobuf wrapper>

The error produced is:

target specifies product type 'com.apple.product-type.tool', but there's no such product type for the 'iphoneos' platform

Granted, I won't really need the protoc target during cross building, but I'd rather stay clear of the CMake files of protobuf.

Ideas ?

TIA
/Robert

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake



--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Protobuf on iOS

Robert Bielik-4
Thanks Craig,

For your thorough answer!

> set(CMAKE_MACOSX_BUNDLE YES)

I did set this so that the protoc app would get through compilation, but since the protobuf cmake/install.cmake file contains the following:

install(TARGETS protoc ... RUNTIME DESTINATION ...) it chokes since BUNDLE DESTINATION is not defined, so I had to add that.

The targets are all static libs so code signing is not a problem at this point.

All the best,
/Robert

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake