diff --git a/src/actions/xcode/xcode_pbxproj.lua b/src/actions/xcode/xcode_pbxproj.lua index 51bce437..684b22e8 100644 --- a/src/actions/xcode/xcode_pbxproj.lua +++ b/src/actions/xcode/xcode_pbxproj.lua @@ -589,8 +589,8 @@ function premake.xcode.pbxproj(sln) tr = xcode.buildtree(sln) - xcode.Header(tr) - xcode.PBXBuildFile(tr) + xcode.Header(tr) -- done + xcode.PBXBuildFile(tr) -- done xcode.PBXFileReference(tr) xcode.PBXFrameworksBuildPhase(tr) xcode.PBXGroup(tr) @@ -601,5 +601,5 @@ xcode.PBXVariantGroup(tr) xcode.XCBuildConfiguration(tr) xcode.XCBuildConfigurationList(tr) - xcode.Footer(tr) + xcode.Footer(tr) -- done end diff --git a/src/actions/xcode/xcode_project.lua b/src/actions/xcode/xcode_project.lua index 0e9938ab..39d9ff3b 100644 --- a/src/actions/xcode/xcode_project.lua +++ b/src/actions/xcode/xcode_project.lua @@ -20,6 +20,32 @@ function xcode.buildprjtree(prj) local tr = premake.project.buildsourcetree(prj) + -- convert localized resources from their filesystem layout (English.lproj/MainMenu.xib) + -- to Xcode's display layout (MainMenu.xib/English). + tree.traverse(tr, { + onbranch = function(node) + if path.getextension(node.name) == ".lproj" then + local lang = path.getbasename(node.name) -- "English", "French", etc. + + -- create a new language group for each file it contains + for _, filenode in ipairs(node.children) do + local grpnode = node.parent.children[filenode.name] + if not grpnode then + grpnode = tree.insert(node.parent, tree.new(filenode.name)) + grpnode.kind = "vgroup" + end + + -- convert the file node to a language node and add to the group + filenode.name = path.getbasename(lang) + tree.insert(grpnode, filenode) + end + + -- remove this directory from the tree + tree.remove(node) + end + end + }) + -- Final setup tree.traverse(tr, { onnode = function(node) diff --git a/tests/actions/test_xcode.lua b/tests/actions/test_xcode.lua index 853efc6b..46f9ef2a 100644 --- a/tests/actions/test_xcode.lua +++ b/tests/actions/test_xcode.lua @@ -27,23 +27,6 @@ end ---------------------------------------------------------------------------- --- PBXBuildFile tests ---------------------------------------------------------------------------- - - - function T.xcode3.PBXBuildFile_ListsResourceFilesOnlyOnceWithGroupID() - files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" } - prepare() - xcode.PBXBuildFile(tr) - test.capture [[ -/* Begin PBXBuildFile section */ - [MainMenu.xib:build] /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = [MainMenu.xib] /* MainMenu.xib */; }; -/* End PBXBuildFile section */ - ]] - end - - --------------------------------------------------------------------------- -- PBXFileReference tests --------------------------------------------------------------------------- diff --git a/tests/actions/xcode/test_xcode_project.lua b/tests/actions/xcode/test_xcode_project.lua index a379ce71..b2c3543a 100644 --- a/tests/actions/xcode/test_xcode_project.lua +++ b/tests/actions/xcode/test_xcode_project.lua @@ -44,3 +44,15 @@ /* End PBXBuildFile section */ ]] end + + + function suite.PBXBuildFile_ListsResourceFilesOnlyOnceWithGroupID() + files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" } + prepare() + xcode.PBXBuildFile(tr) + test.capture [[ +/* Begin PBXBuildFile section */ + [MainMenu.xib:build] /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = [MainMenu.xib] /* MainMenu.xib */; }; +/* End PBXBuildFile section */ + ]] + end