MantisBT - CMake
View Issue Details
0015125CMakeCMakepublic2014-09-03 08:472015-03-02 08:57
Jan Rüegg 
Brad King 
normalminoralways
closedfixed 
CMake 3.0.1 
CMake 3.1CMake 3.1 
0015125: XCode generator cannot add assetcatalog assets
When adding resources to an XCode CMake project like this:

set_target_properties(foo PROPERTIES RESOURCE example/demo_app/Images.xcassets)

An entry similar to this one is created in the xcode project:

1582C9DBB34F4291A1D09CA3 /* Images.xcassets */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = folder; name = Images.xcassets; path = example/demo_app/Images.xcassets; sourceTree = SOURCE_ROOT; };

This works fine for normal folders, however I would like to use this to add an assets folder. This creates a very similar entry, however to make it work with xcode the lastKnownFileType needs to be changed from "folder" to "folder.assetcatalog", like this:

1582C9DBB34F4291A1D09CA3 /* Images.xcassets */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = example/demo_app/Images.xcassets; sourceTree = SOURCE_ROOT; };

In CMake 3.0.1, this is generated in the file "cmGlobalXCodeGenerator.cxx", line 874:
  if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
    {
    fileRef->AddAttribute("lastKnownFileType",
                          this->CreateString("folder"));
    }
In order to make it work, it would need to be changed to read something like this (pseudocode):
  if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
    {
      if (fileEndsWith(".xcassets"))
        {
          fileRef->AddAttribute("lastKnownFileType",
                        this->CreateString("folder.assetcatalog"));
        }
        else
        {
          fileRef->AddAttribute("lastKnownFileType",
                        this->CreateString("folder"));
        }
    }
No tags attached.
Issue History
2014-09-03 08:47Jan RüeggNew Issue
2014-09-03 08:48Jan RüeggNote Added: 0036707
2014-09-03 11:32Brad KingNote Added: 0036723
2014-09-03 11:32Brad KingAssigned To => Brad King
2014-09-03 11:32Brad KingStatusnew => assigned
2014-09-03 11:32Brad KingTarget Version => CMake 3.1
2014-09-04 09:45Brad KingStatusassigned => resolved
2014-09-04 09:45Brad KingResolutionopen => fixed
2014-09-04 09:45Brad KingFixed in Version => CMake 3.1
2015-03-02 08:57Robert MaynardNote Added: 0038105
2015-03-02 08:57Robert MaynardStatusresolved => closed

Notes
(0036707)
Jan Rüegg   
2014-09-03 08:48   
For reference, this is what I'm talking about:
https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/Recipe.html#//apple_ref/doc/uid/TP40013303-CH1-SW1 [^]
(0036723)
Brad King   
2014-09-03 11:32   
This should fix it:

 Xcode: Refactor internal file type extension extraction
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=02aa5965 [^]

 Xcode: Reference '.xcassets' folders as assetcatalog
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8eacc339 [^]

FYI, starting in CMake 3.1 there will be source file properties to override this information without waiting for an update to CMake to do it by default:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst;hb=fb8acb74 [^]
 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst;hb=fb8acb74 [^]
(0038105)
Robert Maynard   
2015-03-02 08:57   
Closing resolved issues that have not been updated in more than 4 months.