From c0df295366dc7e3bead270afd5b0335de2de5213 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Wed, 11 Apr 2018 23:27:33 +1000 Subject: [PATCH 1/3] fix files not being added to root properly --- Sources/XcodeGenKit/SourceGenerator.swift | 14 ++++++++++---- Tests/Fixtures/TestProject/Mintfile | 0 .../TestProject/Project.xcodeproj/project.pbxproj | 2 ++ Tests/Fixtures/TestProject/spec.yml | 3 +++ 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 Tests/Fixtures/TestProject/Mintfile diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 0451ea2f..1966f350 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -440,11 +440,17 @@ class SourceGenerator { let sourceFile = generateSourceFile(targetSource: targetSource, path: path) - let parentGroup = getGroup(path: parentPath, mergingChildren: [fileReference], createIntermediateGroups: createIntermediateGroups, isBaseGroup: true) - - sourcePath = parentPath + if parentPath == spec.basePath { + sourcePath = path + sourceReference = fileReference + rootGroups.insert(fileReference) + } else { + let parentGroup = getGroup(path: parentPath, mergingChildren: [fileReference], createIntermediateGroups: createIntermediateGroups, isBaseGroup: true) + sourcePath = parentPath + sourceReference = parentGroup.reference + } sourceFiles.append(sourceFile) - sourceReference = parentGroup.reference + case .group: let (groupSourceFiles, groups) = try getGroupSources(targetSource: targetSource, path: path, isBaseGroup: true) let group = groups.first! diff --git a/Tests/Fixtures/TestProject/Mintfile b/Tests/Fixtures/TestProject/Mintfile new file mode 100644 index 00000000..e69de29b diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index 0b334a51..835d519e 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -141,6 +141,7 @@ FR_172952167809 /* FrameworkFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FrameworkFile.swift; sourceTree = ""; }; FR_183521624014 /* MyFramework.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyFramework.h; sourceTree = ""; }; FR_196911129660 /* MoreUnder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoreUnder.swift; sourceTree = ""; }; + FR_232605427418 /* Mintfile */ = {isa = PBXFileReference; path = Mintfile; sourceTree = ""; }; FR_238161558082 /* MyBundle.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = MyBundle.bundle; sourceTree = ""; }; FR_247808626608 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; FR_256263906698 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -414,6 +415,7 @@ G_6651250437419 /* StandaloneFiles */, FR_479281060337 /* Folder */, FR_815403394914 /* Headers */, + FR_232605427418 /* Mintfile */, FR_257073931060 /* ResourceFolder */, ); indentWidth = 2; diff --git a/Tests/Fixtures/TestProject/spec.yml b/Tests/Fixtures/TestProject/spec.yml index 06562942..3604eebc 100644 --- a/Tests/Fixtures/TestProject/spec.yml +++ b/Tests/Fixtures/TestProject/spec.yml @@ -42,6 +42,9 @@ targets: - path: Folder type: folder buildPhase: none + - path: Mintfile + type: file + buildPhase: none settings: INFOPLIST_FILE: App_iOS/Info.plist PRODUCT_BUNDLE_IDENTIFIER: com.project.app From 81b8734dfcb3c83e3da1ae231c78de4a89e0d373 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Wed, 11 Apr 2018 23:54:10 +1000 Subject: [PATCH 2/3] support files in fileGroups --- Sources/XcodeGenKit/SourceGenerator.swift | 4 ++-- Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj | 2 ++ Tests/Fixtures/TestProject/SomeFile | 0 Tests/Fixtures/TestProject/spec.yml | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 Tests/Fixtures/TestProject/SomeFile diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 1966f350..07beb1a5 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -48,8 +48,8 @@ class SourceGenerator { // get groups without build files. Use for Project.fileGroups func getFileGroups(path: String) throws { - // TODO: call a seperate function that only creates groups not source files - _ = try getGroupSources(targetSource: TargetSource(path: path), path: spec.basePath + path, isBaseGroup: true) + let fullPath = spec.basePath + path + _ = try getSourceFiles(targetSource: TargetSource(path: path), path: fullPath) } func generateSourceFile(targetSource: TargetSource, path: Path, buildPhase: BuildPhase? = nil) -> SourceFile { diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index 835d519e..ea1d1b19 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -182,6 +182,7 @@ FR_748548478992 /* PushNotificationPayload.apns */ = {isa = PBXFileReference; lastKnownFileType = text; path = PushNotificationPayload.apns; sourceTree = ""; }; FR_752394658615 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Alamofire.framework; sourceTree = ""; }; FR_771029596306 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + FR_775316160345 /* SomeFile */ = {isa = PBXFileReference; path = SomeFile; sourceTree = ""; }; FR_783122899910 /* App_iOS_Tests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = App_iOS_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; FR_815403394914 /* Headers */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Headers; sourceTree = SOURCE_ROOT; }; FR_825232110500 /* App_iOS.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = App_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -417,6 +418,7 @@ FR_815403394914 /* Headers */, FR_232605427418 /* Mintfile */, FR_257073931060 /* ResourceFolder */, + FR_775316160345 /* SomeFile */, ); indentWidth = 2; sourceTree = ""; diff --git a/Tests/Fixtures/TestProject/SomeFile b/Tests/Fixtures/TestProject/SomeFile new file mode 100644 index 00000000..e69de29b diff --git a/Tests/Fixtures/TestProject/spec.yml b/Tests/Fixtures/TestProject/spec.yml index 3604eebc..ea0f3aca 100644 --- a/Tests/Fixtures/TestProject/spec.yml +++ b/Tests/Fixtures/TestProject/spec.yml @@ -10,6 +10,7 @@ options: fileGroups: - Configs - FileGroup + - SomeFile configFiles: Test Debug: Configs/config.xcconfig targets: From e5016afba7aac9c989d1213de0bc8acc72c8c469 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Thu, 12 Apr 2018 00:30:31 +1000 Subject: [PATCH 3/3] update readme for fileGroups --- Docs/ProjectSpec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index ad7eaa06..28c90094 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -35,7 +35,7 @@ Required properties are marked with checkbox. Some of the YAML examples don't sh - [ ] **settings**: **[Settings](#settings)** - Project specific settings. Default base and config type settings will be applied first before any settings defined here - [ ] **settingGroups**: **[Setting Groups](#setting-groups)** - Setting groups mapped by name - [ ] **targets**: **[String: [Target](#target)]** - The list of targets in the project mapped by name -- [ ] **fileGroups**: **[String]** - A list of paths to add to the top level groups. These are files that aren't build files but that you'd like in the project hierachy. For example a folder xcconfig files that aren't already added by any target sources. +- [ ] **fileGroups**: **[String]** - A list of paths to add to the root of the project. These aren't files that will be included in your targets, but that you'd like to include in the project hierachy anyway. For example a folder of xcconfig files that aren't already added by any target sources, or a Readme file. - [ ] **schemes**: **[Scheme](#scheme)** - A list of schemes by name. This allows more control over what is found in [Target Scheme](#target-scheme) ### Include