[cmake-developers] [CMake 0015125]: XCode generator cannot add assetcatalog assets

Mantis Bug Tracker mantis at public.kitware.com
Wed Sep 3 08:47:24 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15125 
====================================================================== 
Reported By:                Jan Rüegg
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15125
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-09-03 08:47 EDT
Last Modified:              2014-09-03 08:47 EDT
====================================================================== 
Summary:                    XCode generator cannot add assetcatalog assets
Description: 
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"));
        }
    }

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-09-03 08:47 Jan Rüegg      New Issue                                    
======================================================================



More information about the cmake-developers mailing list