diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 5fc2f936..6ac82945 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -71,6 +71,9 @@ Note that target names can also be changed by adding a `name` property to a targ - `targets`: only target settings - `none`: no settings are automatically applied - ⚪️ **developmentLanguage**: `String` - Sets the development language of the project. Defaults to `en` +- ⚪️ **usesTabs**: `Bool` - If this is specified, the Xcode project will override the user's setting determining whether or not tabs or spaces should be used in the project. +- ⚪️ **indentWidth**: `Int` - If this is specified, the Xcode project will override the user's setting for indent width in number of spaces. +- ⚪️ **tabWidth**: `Int` - If this is specified, the Xcode project will override the user's setting for indent width in number of spaces. ### Configs Each config maps to a build type of either `debug` or `release` which will then apply default build settings to the project. Any value other than `debug` or `release` (for example `none`), will mean no default build settings will be applied to the project. diff --git a/Sources/ProjectSpec/ProjectSpec.swift b/Sources/ProjectSpec/ProjectSpec.swift index 7fd50320..92480f69 100644 --- a/Sources/ProjectSpec/ProjectSpec.swift +++ b/Sources/ProjectSpec/ProjectSpec.swift @@ -25,6 +25,9 @@ public struct ProjectSpec { public var bundleIdPrefix: String? public var settingPresets: SettingPresets public var developmentLanguage: String? + public var usesTabs: Bool? + public var tabWidth: Int? + public var indentWidth: Int? public enum SettingPresets: String { case all @@ -47,12 +50,15 @@ public struct ProjectSpec { } } - public init(carthageBuildPath: String? = nil, createIntermediateGroups: Bool = false, bundleIdPrefix: String? = nil, settingPresets: SettingPresets = .all, developmentLanguage: String? = nil) { + public init(carthageBuildPath: String? = nil, createIntermediateGroups: Bool = false, bundleIdPrefix: String? = nil, settingPresets: SettingPresets = .all, developmentLanguage: String? = nil, indentWidth: Int? = nil, tabWidth: Int? = nil, usesTabs: Bool? = nil) { self.carthageBuildPath = carthageBuildPath self.createIntermediateGroups = createIntermediateGroups self.bundleIdPrefix = bundleIdPrefix self.settingPresets = settingPresets self.developmentLanguage = developmentLanguage + self.tabWidth = tabWidth + self.indentWidth = indentWidth + self.usesTabs = usesTabs } } @@ -163,5 +169,8 @@ extension ProjectSpec.Options: JSONObjectConvertible { settingPresets = jsonDictionary.json(atKeyPath: "settingPresets") ?? .all createIntermediateGroups = jsonDictionary.json(atKeyPath: "createIntermediateGroups") ?? false developmentLanguage = jsonDictionary.json(atKeyPath: "developmentLanguage") + usesTabs = jsonDictionary.json(atKeyPath: "usesTabs") + indentWidth = jsonDictionary.json(atKeyPath: "indentWidth") + tabWidth = jsonDictionary.json(atKeyPath: "tabWidth") } } diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 45b466ef..64d13766 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -106,7 +106,7 @@ public class PBXProjGenerator { topLevelGroups.insert(rootGroup) } - let mainGroup = PBXGroup(reference: referenceGenerator.generate(PBXGroup.self, "Project"), children: Array(topLevelGroups), sourceTree: .group) + let mainGroup = PBXGroup(reference: referenceGenerator.generate(PBXGroup.self, "Project"), children: Array(topLevelGroups), sourceTree: .group, usesTabs: spec.options.usesTabs.map{ $0 ? 1 : 0 }, indentWidth: spec.options.indentWidth, tabWidth: spec.options.tabWidth) addObject(mainGroup) sortGroups(group: mainGroup) diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index e50204ee..95a66a71 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -312,7 +312,10 @@ G_6651250437419 /* StandaloneFiles */, FR_257073931060 /* ResourceFolder */, ); + indentWidth = 2; sourceTree = ""; + tabWidth = 2; + usesTabs = 0; }; G_8620238527590 /* Products */ = { isa = PBXGroup; diff --git a/Tests/Fixtures/TestProject/spec.yml b/Tests/Fixtures/TestProject/spec.yml index eac4dfe2..9877a310 100644 --- a/Tests/Fixtures/TestProject/spec.yml +++ b/Tests/Fixtures/TestProject/spec.yml @@ -2,6 +2,9 @@ name: Project include: [environments.yml] options: bundleIdPrefix: com.project + usesTabs: false + indentWidth: 2 + tabWidth: 2 fileGroups: - Configs - FileGroup