[cmake-developers] [PATCH] iOS Framework Bundle support

Bartosz Kosiorek Bartosz.Kosiorek at tomtom.com
Thu Nov 12 03:25:17 EST 2015


Hello.

With this tiny little patch, the correct directory structure for iOS Frameworks is created.

The changes are backward compatible (it is not touching OS X at all, only iOS Frameworks).
The risk of regression is very low, as the change is for iOS frameworks, and officially CMake 3.4 do not support iOS.

I tested it manually by using scripts from previous mail for Xcode and Makefile generators, under iOS 9, and it fix directory structure.
After apply this patch, iOS Frameworks created by CMake are working perfectly for me.

Best Regards
Bartosz

________________________________________
From: cmake-developers <cmake-developers-bounces at cmake.org> on behalf of Bartosz Kosiorek <Bartosz.Kosiorek at tomtom.com>
Sent: Wednesday, November 11, 2015 2:19 AM
To: Gregor Jasny; cmake-developers at cmake.org
Subject: Re: [cmake-developers] [PATCH] iOS Framework Bundle support

Hi

Generally I created this cmake scripts to to able to test creating iOS/OSX Application Bundle and iOS/OSX Dynamic Framework Bundle.
By default it produces iOS application Bundle and iOS Framework Bundle.

Steps to reproduce:
1. Download and install CMake 3.4.0
2. Unpack and unpack cmake_shared_ios_framework.zip
3. cd cmake_shared_ios_framework
4. mkdir build
5. cd build
6. ../../../cmake-3.4.0-rc3-Darwin-x86_64/CMake.app/Contents/bin/cmake ..
7. make

Expected result:
- Correct iOS Application Bundle in directory: addDemoCmake.app
- Correct iOS Dynamic Framework Bundle in directory: shared_empty/mul/mul.framework/

Current result:
- Correct iOS Application Bundle in directory: addDemoCmake.app
- Incorrect iOS Dynamic Framework Bundle in directory: shared_empty/mul/mul.framework/
It looks like:

find mul.framework/
mul.framework/
mul.framework//Headers
mul.framework//Headers/mul.h
mul.framework//Modules
mul.framework//Modules/module.modulemap
mul.framework//mul
mul.framework//Resources
mul.framework//Resources/Info.plist
mul.framework//Versions
mul.framework//Versions/Current

What it wrong in with that Framework :
1. Xcode expect that iOS Framework have Info.plist in main Framework directory (mul.framework/Info.plist).
2. mul.framework//Versions/ and mul.framework//Resources is not needed and shouldn't be produced (Info.plist should be moved to root Framework directory)
3. mul.framework//Versions/Current symlink is pointing to not existing "A" version directory

Now I see that my patch should be simplified to few lines. I will provide fix later.
My previous wrong assumption was that CMake 3.4 do not change anything in creating iOS Bundles.

@Gregor Do you think it will be possible to fix that issue in CMake 3.4.0, to have full support for iOS (both from Application and Frameworks) ?

Best Regards
Bartosz
________________________________________
From: Gregor Jasny <gjasny at googlemail.com>
Sent: Tuesday, November 10, 2015 9:54 PM
To: Bartosz Kosiorek; cmake-developers at cmake.org
Subject: Re: [cmake-developers] [PATCH] iOS Framework Bundle support

Hello,

On 10/11/15 16:22, Bartosz Kosiorek wrote:
> My name is Bartosz Kosiorek and I'm TomTom developer and Open Source enthusiast.

I'm Gregor a part time contributor to CMake. During the last months I
mostly worked on Xcode support.

> Last time in our products, we notice that cmake is not creating correct iOS Frameworks Bundle.
> For iOS Frameworks, not versioned Bundle is needed, eg.:
>
>   iOSFramework.framework/
>       iOSFramework
>       Info.plist
>       Headers
>
>
>
> Unfortunately with current version of CMake (3.4.0), it produces OS X Framework Bundle, with versions inside, eg.:
>
>   MyFramework.framework/
>     MyFramework -> Versions/Current/MyFramework
>     Resources -> Versions/Current/Resources
>     Versions/
>         A/
>             MyFramework
>             Headers
>             Resources/
>                  Info.plist
>         Current -> A
>
>
>
> You could test it with my example project in attachment (cmake_shared_ios_framework.zip).

Unfortunately I cannot reproduce the problem. Could you please write
down the exact steps you took to compile the example in the zip file?
Please also Xcode and cmake version.

That's what I see (cmake master, Xcode generator and Xcode 7.1):

$ find _build/shared_empty/mul/Debug-iphonesimulator/mul.framework
_build/shared_empty/mul/Debug-iphonesimulator/mul.framework
_build/shared_empty/mul/Debug-iphonesimulator/mul.framework/Headers
_build/shared_empty/mul/Debug-iphonesimulator/mul.framework/Headers/mul.h
_build/shared_empty/mul/Debug-iphonesimulator/mul.framework/Info.plist
_build/shared_empty/mul/Debug-iphonesimulator/mul.framework/Modules
_build/shared_empty/mul/Debug-iphonesimulator/mul.framework/Modules/module.modulemap
_build/shared_empty/mul/Debug-iphonesimulator/mul.framework/mul

> The iOS Application Bundle was already fixed in CMake 3.4.0. Unfortunately still iOS Frameworks are not produced correctly (Xcode refuses to sign such Frameworks if you would like to push it into iOS device).
>
> In attachment I added solution to produce correct iOS Framework (for OSX Frameworks will be produced normally).
>
>
>
> Could you please give some comment about that?
>
> Do you think architecture of that solution is correct?

I'd go for an early return from cmOSXBundleGenerator::CreateFramework if
we're building for iOS. The code of CreateIOSFramework is just too similar.

> I would like to do next:
>
> - Refactor code, to have more explicitly names (OSX, iOS or Apple)
>
> - Update documentation
>
> - add some unit tests for creating iOS Frameworks

I would like to see a test for that topic. If you'd like to try please
have a look at:
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=744e6c497c01cb3a3129ca66d1cabfa83e17dbd4
https://cmake.org/gitweb?p=cmake.git;a=tree;f=Tests/RunCMake/XcodeProject;hb=HEAD
https://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/RunCMake/README.rst;hb=HEAD

You need to build cmake via the Xcode generator and run the tests.
During development you can filter just for the XcodeProject tests:

bin/Debug/ctest -R RunCMake.XcodeProject --verbose

Thanks,
Gregor
--

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-developers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-iOS-Framework-directory-structure-15833.patch
Type: application/octet-stream
Size: 5590 bytes
Desc: 0001-Fix-iOS-Framework-directory-structure-15833.patch
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20151112/df7ce25f/attachment.obj>


More information about the cmake-developers mailing list