[CMake] iOS multi-arch library target and xcodebuild

Eric Wing ewmailing at gmail.com
Thu Jun 25 05:14:40 EDT 2015


> * iOS toolchains I'm using: https://github.com/ruslo/polly (used to
> switch between different SDKs + to add some flags, like -std=c++11)

Do you have to use a different toolchain for every different variant
and different OS version? That's rather unfortunate if so. My current
tweaks don't require this.

> * when I run "Archive" for preparing my application for uploading to
> AppStore Xcode uses only device architectures. Just set "Build Active
> Architecture Only" to NO and universal application for device will be built

I think I saw this mentioned elsewhere and am employing that. Still,
I'm a little concerned this might be a hack that is working around a
more underlying problem that could break.

> * I see no point of using frameworks for managing 3rd parties. Plain
> `<root>/include` and `<root>/lib` layout works for iOS (and for all
> others platforms like MSVC, MinGW, ...)

Frameworks vs. dylibs isn't the issue at all here and completely
misses the point. The point is the way FIND_LIBRARIES anchors absolute
paths to everything. This won't work with SYSTEM framewoks because the
paths dynamically change depending on device or simulator.  3rd party
fat binaries installed in a single location regardless of frameworks
or dylibs. This is annoying because you must remember whether you are
dealing with a system provided library or a third party library in the
way you write your CMake files now.

A disgression: my understanding is that for iOS, officially for 3rd
party dynamic libraries, only frameworks and not dylibs are supported.



> * Hunter automatically set CMAKE_PREFIX_PATH and <package>_ROOT to the
> root directory of 3rd party libraries so `find_package` works fine

Okay, I think I've done something similar by setting the
CMAKE_ROOT_PATH to look in the CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH,
CMAKE_INCLUDE_PATH. I needed this for Android's NDK Module system
convention too.



> * toolchain used to switch between different SDK's. You just need to set
> environment variable IOS_X_Y_DEVELOPER_DIR. See
> https://github.com/ruslo/polly/wiki/Toolchain-list#ios

Okay, I think my tweaks have done better than this. I don't need to
set any environmental variable changes. I can use the built-in Xcode
UI to switch between SDKs and my tweaks are mostly agnostic to which
iOS SDK version you have. (It always detects the default installed.)
My concerns are not merely one-shot automation builds. I do manual,
every day development in Xcode and expect/follow a mostly natural
Xcode developer work flow and other developers on the platform expect
the same. Being able to switch between simulator and device without a
roundtrip CMake generation is extremely useful (and expected), along
with being able to test the different architecture variants (32-bit,
64-bit).


I plan to do a write up of some kind to show my workflow and present
my tweaks I made to try to improve things for all the platforms I work
on to make the every day workflows more natural for each respective
platform.


But I do suspect the fat device/simulator binary build patch would be
very useful to have.

Thanks,
Eric


More information about the CMake mailing list