MantisBT - CMake
View Issue Details
0014498CMakeCMakepublic2013-10-21 05:512014-03-05 09:58
Michael Priestman 
Brad King 
normalminoralways
closedfixed 
AppleMac OS X10.8.5
CMake 2.8.12 
CMake 3.0CMake 3.0 
0014498: Folder references aren't added correctly to Xcode projects.
With the change that fixed issue 0014093, another issue has arisen.

If you try to add a folder reference into an Xcode project, then the incorrect file type is set on the reference, and Xcode cannot access the files inside the folder, saying instead that it has no permissions.

I have a folder that contains some image assets for an iOS project, and I want to just add the entire folder (which has subfolders) to an Xcode project. I do this by just including the path to the folder.

With CMake 2.8.11.02, this worked fine. But with the change mentioned above, the reference now has an "explicitFileType" attribute, which is set to "sourcecode". It appears Xcode isn't happy with this.

If you add a folder reference to an Xcode project, I think the explicitFileType attribute should be set to "folder". I discovered this by explicitly setting the file type in Xcode to "Directory" and resaving the project. If you do this, then Xcode can once again access the contents of the folder.

So whilst technically this could be a bug with Xcode (tested with 4 and 5, same behaviour), I don't think it should be too hard to fix in CMake. If you can tell a given source file reference is actually a folder reference, then you can just say the explicitFileType is "folder" instead of "sourcecode".

This isn't a major issue as if you want to access the folder in Xcode, you can just manually update the file type, but obviously you'd have to do that each time you regenerate the project.
Create a directory that contains a simple source file and single folder that contains, say, an image.

Create a simple CMake file that defines a library that contains a reference to the folder.

Generate an XCode project from the CMake file.

Load XCode project, and try to navigate to the folder. You will get an error.

Set the file type to "Directory", then you can access the contents of the folder.

Attached is a sample that demonstrates this problem.
No tags attached.
related to 0014093closed Brad King Xcode 4.6 ignores "lastKnownFileType" for .txx files 
zip sample.zip (64,472) 2013-10-21 05:51
https://public.kitware.com/Bug/file/4912/sample.zip
patch 0001-Updated-Xcode-generator-to-set-lastKnownFileType-to-.patch (2,191) 2013-10-21 10:57
https://public.kitware.com/Bug/file/4915/0001-Updated-Xcode-generator-to-set-lastKnownFileType-to-.patch
Issue History
2013-10-21 05:51Michael PriestmanNew Issue
2013-10-21 05:51Michael PriestmanFile Added: sample.zip
2013-10-21 08:52Brad KingRelationship addedrelated to 0014093
2013-10-21 08:55Brad KingNote Added: 0034181
2013-10-21 09:52Jamie SnapeNote Added: 0034188
2013-10-21 10:27Michael PriestmanNote Added: 0034192
2013-10-21 10:31Michael PriestmanNote Added: 0034193
2013-10-21 10:39Jamie SnapeNote Added: 0034197
2013-10-21 10:42Brad KingNote Added: 0034199
2013-10-21 10:49Michael PriestmanNote Added: 0034201
2013-10-21 10:55Jamie SnapeNote Added: 0034203
2013-10-21 10:56Jamie SnapeNote Edited: 0034203bug_revision_view_page.php?bugnote_id=34203#r1287
2013-10-21 10:56Brad KingNote Added: 0034204
2013-10-21 10:56Jamie SnapeNote Edited: 0034203bug_revision_view_page.php?bugnote_id=34203#r1288
2013-10-21 10:57Michael PriestmanFile Added: 0001-Updated-Xcode-generator-to-set-lastKnownFileType-to-.patch
2013-10-21 11:01Michael PriestmanNote Added: 0034205
2013-10-21 11:31Brad KingNote Added: 0034211
2013-10-21 11:32Brad KingAssigned To => Brad King
2013-10-21 11:32Brad KingStatusnew => resolved
2013-10-21 11:32Brad KingResolutionopen => fixed
2013-10-21 11:32Brad KingFixed in Version => CMake 3.0
2013-10-21 11:32Brad KingTarget Version => CMake 3.0
2014-03-05 09:58Robert MaynardNote Added: 0035293
2014-03-05 09:58Robert MaynardStatusresolved => closed

Notes
(0034181)
Brad King   
2013-10-21 08:55   
Take a look at the logic here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalXCodeGenerator.cxx;hb=v2.8.12#l844 [^]

Try adding a test for cmSystemTools::FileIsDirectory(fullpath) to change the explicitFileType value.
(0034188)
Jamie Snape   
2013-10-21 09:52   
I can reproduce the issue with Xcode 5.0.1. Setting

explicitFileType = folder

in the pbxproj does indeed resolve the issue for me. See also

Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Versions/A/Resources/Built-in file types.pbfilespec
(0034192)
Michael Priestman   
2013-10-21 10:27   
I've just tried setting explicitFileType to be folder, and on Xcode 4.6.1, this didn't work. I had to set "lastKnownFileType" to be "folder" in order to get it working.

I can try Xcode 5.0.1 as well and see if this is something dependent on Xcode version.
(0034193)
Michael Priestman   
2013-10-21 10:31   
Alternatively, just not setting lastKnownFileType or explicitFileType also fixes the problem, but not sure what other implications this would have. So maybe best to just set lastKnownFileType to "folder".
(0034197)
Jamie Snape   
2013-10-21 10:39   
Sorry, you're correct, I should have said

lastKnownFileType = folder

On further investigation, setting the file type in the GUI for folders corresponds to "lastKnownFileType" rather than "explicitFileType".
(0034199)
Brad King   
2013-10-21 10:42   
Re 0014498:0034197: That's why we used to generate lastKnownFileType, but behavior in 0014093 said differently.

Please try the approach I suggested in 0014498:0034181 to use lastKnownFileType=folder for directories and keep the current behavior otherwise.
(0034201)
Michael Priestman   
2013-10-21 10:49   
Yep, that's what I have just tried. I have a patch for master that I think fixes this problem. What would be the next steps? I've never contributed anything to the CMake project before. I could attach the patch to this report for testing by other people?
(0034203)
Jamie Snape   
2013-10-21 10:55   
(edited on: 2013-10-21 10:56)
Re 0014498:0034199: The behavior of the GUI with respect to folders is apparently different than with files. The behavior in 0014093 is otherwise correct as Xcode is still basically ignoring lastKnownFileType for files.

(0034204)
Brad King   
2013-10-21 10:56   
Re 0014498:0034201: Great, please use "git format-patch" to export the patch and attach the file here. Please explain in the commit message what we know about why this is needed. Thanks!
(0034205)
Michael Priestman   
2013-10-21 11:01   
Patch attached. I have updated the function you mentioned to add the "lastKnownFileType" attribute if it's a folder, otherwise use the existing code.

Had to also put a check in for "explicitFileType" attribute in CreateXCodeTargets as now it might not be present. Think this behaviour makes sense as folders should never be classified as externalObjFiles.
(0034211)
Brad King   
2013-10-21 11:31   
Re 0014498:0034205: Patch applied with minor tweaks:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e5ec8ad4 [^]
(0035293)
Robert Maynard   
2014-03-05 09:58   
Closing resolved issues that have not been updated in more than 4 months