diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 1251362f..3b52bd0c 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -76,11 +76,11 @@ Note that target names can also be changed by adding a `name` property to a targ - [ ] **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. - [ ] **xcodeVersion**: **String** - The version of Xcode. This defaults to the latest version periodically. You can specify it in the format `0910` or `9.1` -- [ ] **deploymentTargets**: **[[Platform](#platform): String]** - A project wide deployment target can be specified for each platform otherwise the default SDK version in Xcode will be used. This will be overridden by any custom build settings that set the deployment target eg `IPHONEOS_DEPLOYMENT_TARGET`. Target specific deployment targets can also be set with [Target](#target).deploymentTarget. +- [ ] **deploymentTarget**: **[[Platform](#platform): String]** - A project wide deployment target can be specified for each platform otherwise the default SDK version in Xcode will be used. This will be overridden by any custom build settings that set the deployment target eg `IPHONEOS_DEPLOYMENT_TARGET`. Target specific deployment targets can also be set with [Target](#target).deploymentTarget. ```yaml options: - deploymentTargets: + deploymentTarget: watchOS: 2.0 tvOS: 10.0 ``` @@ -145,7 +145,7 @@ Settings are merged in the following order: groups, base, configs. - [x] **type**: **[Product Type](#product-type)** - Product type of the target - [x] **platform**: **[Platform](#platform)** - Platform of the target -- [ ] **deploymentTarget**: **String or Double** - The deployment target eg (11.0). If this is not specified the value from the project set in [Options](#options)`.deploymentTargets.PLATFORM` will be used. +- [ ] **deploymentTarget**: **String or Double** - The deployment target eg (11.0). If this is not specified the value from the project set in [Options](#options)`.deploymentTarget.PLATFORM` will be used. - [ ] **sources**: **[Sources](#sources)** - Source directories of the target - [ ] **configFiles**: **[Config Files](#config-files)** - `.xcconfig` files per config - [ ] **settings**: **[Settings](#settings)** - Target specific build settings. Default platform and product type settings will be applied first before any custom settings defined here. Other context dependant settings will be set automatically as well: diff --git a/Sources/ProjectSpec/DeploymentTargets.swift b/Sources/ProjectSpec/DeploymentTarget.swift similarity index 91% rename from Sources/ProjectSpec/DeploymentTargets.swift rename to Sources/ProjectSpec/DeploymentTarget.swift index c568367e..05848b77 100644 --- a/Sources/ProjectSpec/DeploymentTargets.swift +++ b/Sources/ProjectSpec/DeploymentTarget.swift @@ -9,7 +9,7 @@ import Foundation import xcproj import JSONUtilities -public struct DeploymentTargets: Equatable { +public struct DeploymentTarget: Equatable { public var iOS: Version? public var tvOS: Version? @@ -32,7 +32,7 @@ public struct DeploymentTargets: Equatable { } } - public static func == (lhs: DeploymentTargets, rhs: DeploymentTargets) -> Bool { + public static func == (lhs: DeploymentTarget, rhs: DeploymentTarget) -> Bool { return lhs.iOS == rhs.iOS && lhs.tvOS == rhs.tvOS && lhs.watchOS == rhs.watchOS && @@ -60,7 +60,7 @@ extension Version { } } -extension DeploymentTargets: JSONObjectConvertible { +extension DeploymentTarget: JSONObjectConvertible { public init(jsonDictionary: JSONDictionary) throws { diff --git a/Sources/ProjectSpec/ProjectSpec.swift b/Sources/ProjectSpec/ProjectSpec.swift index 8d4e597b..0048216a 100644 --- a/Sources/ProjectSpec/ProjectSpec.swift +++ b/Sources/ProjectSpec/ProjectSpec.swift @@ -29,7 +29,7 @@ public struct ProjectSpec { public var tabWidth: Int? public var indentWidth: Int? public var xcodeVersion: String? - public var deploymentTargets: DeploymentTargets + public var deploymentTarget: DeploymentTarget public enum SettingPresets: String { case all @@ -52,7 +52,7 @@ public struct ProjectSpec { } } - 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, xcodeVersion: String? = nil, deploymentTargets: DeploymentTargets = .init()) { + 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, xcodeVersion: String? = nil, deploymentTarget: DeploymentTarget = .init()) { self.carthageBuildPath = carthageBuildPath self.createIntermediateGroups = createIntermediateGroups self.bundleIdPrefix = bundleIdPrefix @@ -62,7 +62,7 @@ public struct ProjectSpec { self.indentWidth = indentWidth self.usesTabs = usesTabs self.xcodeVersion = xcodeVersion - self.deploymentTargets = deploymentTargets + self.deploymentTarget = deploymentTarget } public static func == (lhs: ProjectSpec.Options, rhs: ProjectSpec.Options) -> Bool { @@ -75,7 +75,7 @@ public struct ProjectSpec { lhs.indentWidth == rhs.indentWidth && lhs.usesTabs == rhs.usesTabs && lhs.xcodeVersion == rhs.xcodeVersion && - lhs.deploymentTargets == rhs.deploymentTargets + lhs.deploymentTarget == rhs.deploymentTarget } } @@ -178,6 +178,6 @@ extension ProjectSpec.Options: JSONObjectConvertible { usesTabs = jsonDictionary.json(atKeyPath: "usesTabs") indentWidth = jsonDictionary.json(atKeyPath: "indentWidth") tabWidth = jsonDictionary.json(atKeyPath: "tabWidth") - deploymentTargets = jsonDictionary.json(atKeyPath: "deploymentTargets") ?? DeploymentTargets() + deploymentTarget = jsonDictionary.json(atKeyPath: "deploymentTarget") ?? DeploymentTarget() } } diff --git a/Sources/XcodeGenKit/SettingsBuilder.swift b/Sources/XcodeGenKit/SettingsBuilder.swift index 32b7388b..1d6a8b63 100644 --- a/Sources/XcodeGenKit/SettingsBuilder.swift +++ b/Sources/XcodeGenKit/SettingsBuilder.swift @@ -17,7 +17,7 @@ extension ProjectSpec { // apply custom platform version for platform in Platform.all { - if let version = options.deploymentTargets.version(for: platform) { + if let version = options.deploymentTarget.version(for: platform) { buildSettings[platform.deploymentTargetSetting] = version.deploymentTarget } } diff --git a/Tests/Fixtures/TestProject/spec.yml b/Tests/Fixtures/TestProject/spec.yml index 3b12705d..e7ca6238 100644 --- a/Tests/Fixtures/TestProject/spec.yml +++ b/Tests/Fixtures/TestProject/spec.yml @@ -5,7 +5,7 @@ options: usesTabs: false indentWidth: 2 tabWidth: 2 - deploymentTargets: + deploymentTarget: watchOS: 2.0 fileGroups: - Configs diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 891dea18..b1d4d253 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -166,7 +166,7 @@ func projectGeneratorTests() { $0.it("generates platform version") { let target = Target(name: "Target", type: .application, platform: .watchOS, deploymentTarget: "2.0") - let spec = ProjectSpec(basePath: "", name: "", targets: [target], options: .init(deploymentTargets: DeploymentTargets(iOS: "10.0", watchOS: "3.0"))) + let spec = ProjectSpec(basePath: "", name: "", targets: [target], options: .init(deploymentTarget: DeploymentTarget(iOS: "10.0", watchOS: "3.0"))) let pbxProject = try getPbxProj(spec) diff --git a/Tests/XcodeGenKitTests/SpecLoadingTests.swift b/Tests/XcodeGenKitTests/SpecLoadingTests.swift index 58b435cc..7c7608d8 100644 --- a/Tests/XcodeGenKitTests/SpecLoadingTests.swift +++ b/Tests/XcodeGenKitTests/SpecLoadingTests.swift @@ -230,7 +230,7 @@ func specLoadingTests() { createIntermediateGroups: true, bundleIdPrefix: "com.test", developmentLanguage: "ja", - deploymentTargets: DeploymentTargets( + deploymentTarget: DeploymentTarget( iOS: "11.1", tvOS: "10.0", watchOS: "3.0", @@ -241,7 +241,7 @@ func specLoadingTests() { "bundleIdPrefix": "com.test", "createIntermediateGroups": true, "developmentLanguage": "ja", - "deploymentTargets": ["iOS": 11.1, "tvOS": 10.0, "watchOS": "3", "macOS": "10.12.1" ] + "deploymentTarget": ["iOS": 11.1, "tvOS": 10.0, "watchOS": "3", "macOS": "10.12.1" ] ]] let parsedSpec = try getProjectSpec(dictionary) try expect(parsedSpec) == expected