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 diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 0451ea2f..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 { @@ -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..ea1d1b19 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 = ""; }; @@ -181,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; }; @@ -414,7 +416,9 @@ G_6651250437419 /* StandaloneFiles */, FR_479281060337 /* Folder */, 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 06562942..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: @@ -42,6 +43,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