MantisBT - CMake
View Issue Details
0015833CMakeCMakepublic2015-11-05 11:292016-06-06 13:37
Bartosz 
Gregor Jasny 
normalminoralways
closedfixed 
OSX
 
CMake 3.5CMake 3.5 
0015833: Support creating of Framework for iOS
The framework from Apple is specific directory structure.

For OS X it is using versioned directory structue.
The directory structure looks like:
MyFramework.framework/
    MyFramework -> Versions/Current/MyFramework
    Resources -> Versions/Current/Resources
    Versions/
        A/
            MyFramework
            Headers
            Resources/
                English.lproj/
                    InfoPlist.strings
                Info.plist
        Current -> A


More info:
https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html#//apple_ref/doc/uid/20002253-BAJEJJAB [^]


These structure is used when you specify following target variables:
set_target_properties(MyFramework PROPERTIES
  FRAMEWORK TRUE
  FRAMEWORK_VERSION A
  MACOSX_FRAMEWORK_IDENTIFIER com.cmake.myframework
)


For iOS the "flat" directory structure is used.
It looks like:
iOSFramework.framework/
      iOSFramework
      Info.plist
      Headers
      Resources/
            English.lproj/
                 InfoPlist.strings

Currently it is not possible to create "flat" directory structure which could be used for iOS.

Solution proposal:
Allow possibility to create "flat" framework.
The flat framework will be produced when IOS_FRAMEWORK will be set to TRUE
For example:

set_target_properties(MyFramework PROPERTIES
  IOS_FRAMEWORK TRUE
  MACOSX_FRAMEWORK_IDENTIFIER com.cmake.myframework
)

I would like to implement that, and provide patches to cmake.
I need some architectural support from you.


Maybe also I could fix:
https://public.kitware.com/Bug/view.php?id=15820 [^]
No tags attached.
related to 0015843closed Gregor Jasny Documentation is not mention about support for iOS Application Bundle and iOS Framework Bundle 
patch iOS-Dynamic_Framework_support.patch (670) 2015-11-06 11:03
https://public.kitware.com/Bug/file/5567/iOS-Dynamic_Framework_support.patch
zip cmake_shared_ios_framework.zip (6,095) 2015-11-06 11:06
https://public.kitware.com/Bug/file/5568/cmake_shared_ios_framework.zip
patch 0001-Add-support-for-iOS-Frameworks-bug-15833.patch (3,501) 2015-11-09 17:20
https://public.kitware.com/Bug/file/5570/0001-Add-support-for-iOS-Frameworks-bug-15833.patch
patch 0001-Fix-iOS-Framework-directory-structure-15833.patch (5,590) 2015-11-12 03:26
https://public.kitware.com/Bug/file/5574/0001-Fix-iOS-Framework-directory-structure-15833.patch
Issue History
2015-11-05 11:29BartoszNew Issue
2015-11-06 03:29BartoszNote Added: 0039840
2015-11-06 11:03BartoszFile Added: iOS-Dynamic_Framework_support.patch
2015-11-06 11:06BartoszFile Added: cmake_shared_ios_framework.zip
2015-11-06 11:12BartoszNote Added: 0039845
2015-11-06 11:12BartoszNote Edited: 0039845bug_revision_view_page.php?bugnote_id=39845#r1950
2015-11-09 03:45BartoszNote Added: 0039848
2015-11-09 05:05BartoszNote Edited: 0039848bug_revision_view_page.php?bugnote_id=39848#r1954
2015-11-09 17:20BartoszFile Added: 0001-Add-support-for-iOS-Frameworks-bug-15833.patch
2015-11-10 04:33BartoszNote Added: 0039853
2015-11-10 08:37Brad KingAssigned To => Gregor Jasny
2015-11-10 08:37Brad KingStatusnew => assigned
2015-11-10 08:37Brad KingTarget Version => CMake 3.5
2015-11-10 13:15Brad KingNote Added: 0039859
2015-11-12 03:26BartoszFile Added: 0001-Fix-iOS-Framework-directory-structure-15833.patch
2015-11-13 08:06Gregor JasnyNote Added: 0039868
2015-11-16 09:21Brad KingNote Added: 0039871
2015-11-16 10:01BartoszNote Added: 0039872
2015-11-16 10:14Brad KingRelationship addedrelated to 0015843
2015-12-09 15:04BartoszNote Added: 0039962
2015-12-09 15:10Brad KingNote Added: 0039964
2015-12-09 15:10Brad KingStatusassigned => resolved
2015-12-09 15:10Brad KingResolutionopen => fixed
2015-12-09 15:10Brad KingFixed in Version => CMake 3.5
2016-05-02 08:30Robert MaynardNote Added: 0040981
2016-05-02 08:30Robert MaynardStatusresolved => closed
2016-06-06 13:37Brad KingView Statusprivate => public

Notes
(0039840)
Bartosz   
2015-11-06 03:29   
I just notified that flat directory structure is created (for iOS), when cmMakefile::PlatformIsAppleIos() is return true.

It seems that it returns true when CMAKE_OSX_SYSROOT is set to:
  "appletvos", "appletvsimulator",
  "iphoneos", "iphonesimulator",
  "watchos", "watchsimulator",
(0039845)
Bartosz   
2015-11-06 11:12   
In attachment you could find the patch for support Dynamic Frameworks for iOS.
I tested it with my small custom project (see attachment), and by manually checking "ID" of the shared library:
  
otool -L shared_empty/mul/mul.framework/mul
shared_empty/mul/mul.framework/mul:
    @rpath/mul.framework/mul (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.dylib (compatibility version 1.0.0, current version 1226.10.1)

It is very important for Xcode signing, to have properly set "id" (first line).

I was using following CMakeLists.txt script to generate Framework for iOS:

set_property(SOURCE module.modulemap
  PROPERTY MACOSX_PACKAGE_LOCATION "Modules")
set(CMAKE_MACOSX_RPATH ON)
# add the main library
add_library(mul SHARED
            mul.c
            mul.h
            module.modulemap)
# Create an iOS Framework bundle
set_target_properties(mul PROPERTIES
  FRAMEWORK TRUE
  MACOSX_FRAMEWORK_IDENTIFIER com.cmake.mul
  MACOSX_FRAMEWORK_SHORT_VERSION_STRING 42
  MACOSX_FRAMEWORK_BUNDLE_VERSION 3.2.10
  XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
  #FRAMEWORK_VERSION 42 #We don’t need version for iOS Framework
  PUBLIC_HEADER mul.h
)


I would like to test it more on our production code (I will do that on Monday).
Please take a look at this patch, and tell me if my solution is correct.

(0039848)
Bartosz   
2015-11-09 03:45   
(edited on: 2015-11-09 05:05)
Unfortunately I didn't attached correct patch (sic!).
I will fix that later today.

Meantime I would like to add support for creation of iOS application support.
For iOS systems, the directory structure for Application/Bundle is wrong and it is unable to run on iOS Device/Simulator.

(0039853)
Bartosz   
2015-11-10 04:33   
I just noticed that for CMake 3.4.0 RC3 the Application Bundle for iOS is generated properly!
Thanks.

Unfortunately still iOS Frameworks Bundle is created versioning.
Could you please apply this patch to fix that issue?
(0039859)
Brad King   
2015-11-10 13:15   
Corresponding mailing list thread:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/14908 [^]
(0039868)
Gregor Jasny   
2015-11-13 08:06   
Pushed to non-xcode-framework-layout topic and merged to next
(0039871)
Brad King   
2015-11-16 09:21   
Re 0015833:0039868: For reference, the changes in that topic are:

 Fix iOS Framework directory structure
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f053763 [^]

 Add test for OSX/iOS Framework directory structure
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f6f03ed4 [^]
(0039872)
Bartosz   
2015-11-16 10:01   
Thanks Brad.

Can we also push documentation update:
https://cmake.org/Bug/view.php?id=15843 [^]
?
(0039962)
Bartosz   
2015-12-09 15:04   
We could close this ticket. The solution is already pushed into next branch
(0039964)
Brad King   
2015-12-09 15:10   
The changes linked by 0015833:0039871 are now in 'master'.
(0040981)
Robert Maynard   
2016-05-02 08:30   
Closing resolved issues that have not been updated in more than 4 months.