rename platformVersion to deploymentTarget

This commit is contained in:
Yonas Kolb committed 2017-12-26 17:36:41 +08:00
1 parent 4a90d33951
commit cd6d179325
9 files changed
+49 -53

No files matched your search

+3 -7
View File
@@ -76,15 +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`
- [ ] **platformVersions**: **[String: String]** - A project wide SDK version can be specified for each platform otherwise the default SDK version in Xcode will be used. This will be overriden by any custom build settings that also apply a version eg `IPHONEOS_DEPLOYMENT_TARGET`. The available platforms are:
- iOS
- tvOS
- watchOS
- macOS
- [ ] **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.
```yaml
options:
platformVersions:
deploymentTargets:
watchOS: 2.0
tvOS: 10.0
```
@@ -149,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
- [ ] **platformVersion**: **String or Double** - The SDK version to use. If this is not specified the value from the project set in [Options](#options)`.platformVersions.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)`.deploymentTargets.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:
@@ -9,7 +9,7 @@ import Foundation
import xcproj
import JSONUtilities
public struct PlatformVersions: Equatable {
public struct DeploymentTargets: Equatable {
public var iOS: Version?
public var tvOS: Version?
@@ -32,7 +32,7 @@ public struct PlatformVersions: Equatable {
}
}
public static func == (lhs: PlatformVersions, rhs: PlatformVersions) -> Bool {
public static func == (lhs: DeploymentTargets, rhs: DeploymentTargets) -> Bool {
return lhs.iOS == rhs.iOS &&
lhs.tvOS == rhs.tvOS &&
lhs.watchOS == rhs.watchOS &&
@@ -42,7 +42,7 @@ public struct PlatformVersions: Equatable {
extension Platform {
public var versionBuildSetting: String {
public var deploymentTargetSetting: String {
switch self {
case .iOS: return "IPHONEOS_DEPLOYMENT_TARGET"
case .tvOS: return "TVOS_DEPLOYMENT_TARGET"
@@ -54,13 +54,13 @@ extension Platform {
extension Version {
/// doesn't print patch
public var platformVersion: String {
/// doesn't print patch if 0
public var deploymentTarget: String {
return "\(major).\(minor)\(patch > 0 ? ".\(patch)" : "")"
}
}
extension PlatformVersions: JSONObjectConvertible {
extension DeploymentTargets: JSONObjectConvertible {
public init(jsonDictionary: JSONDictionary) throws {
+5 -5
View File
@@ -29,7 +29,7 @@ public struct ProjectSpec {
public var tabWidth: Int?
public var indentWidth: Int?
public var xcodeVersion: String?
public var platformVersions: PlatformVersions
public var deploymentTargets: DeploymentTargets
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, platformVersions: PlatformVersions = .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, deploymentTargets: DeploymentTargets = .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.platformVersions = platformVersions
self.deploymentTargets = deploymentTargets
}
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.platformVersions == rhs.platformVersions
lhs.deploymentTargets == rhs.deploymentTargets
}
}
@@ -178,6 +178,6 @@ extension ProjectSpec.Options: JSONObjectConvertible {
usesTabs = jsonDictionary.json(atKeyPath: "usesTabs")
indentWidth = jsonDictionary.json(atKeyPath: "indentWidth")
tabWidth = jsonDictionary.json(atKeyPath: "tabWidth")
platformVersions = jsonDictionary.json(atKeyPath: "platformVersions") ?? PlatformVersions()
deploymentTargets = jsonDictionary.json(atKeyPath: "deploymentTargets") ?? DeploymentTargets()
}
}
+9 -9
View File
@@ -30,7 +30,7 @@ public struct Target {
public var configFiles: [String: String]
public var scheme: TargetScheme?
public var legacy: LegacyTarget?
public var platformVersion: Version?
public var deploymentTarget: Version?
public var isLegacy: Bool {
return legacy != nil
@@ -44,11 +44,11 @@ public struct Target {
return name
}
public init(name: String, type: PBXProductType, platform: Platform, platformVersion: Version? = nil, settings: Settings = .empty, configFiles: [String: String] = [:], sources: [TargetSource] = [], dependencies: [Dependency] = [], prebuildScripts: [BuildScript] = [], postbuildScripts: [BuildScript] = [], scheme: TargetScheme? = nil, legacy: LegacyTarget? = nil) {
public init(name: String, type: PBXProductType, platform: Platform, deploymentTarget: Version? = nil, settings: Settings = .empty, configFiles: [String: String] = [:], sources: [TargetSource] = [], dependencies: [Dependency] = [], prebuildScripts: [BuildScript] = [], postbuildScripts: [BuildScript] = [], scheme: TargetScheme? = nil, legacy: LegacyTarget? = nil) {
self.name = name
self.type = type
self.platform = platform
self.platformVersion = platformVersion
self.deploymentTarget = deploymentTarget
self.settings = settings
self.configFiles = configFiles
self.sources = sources
@@ -140,7 +140,7 @@ extension Target: Equatable {
return lhs.name == rhs.name &&
lhs.type == rhs.type &&
lhs.platform == rhs.platform &&
lhs.platformVersion == rhs.platformVersion &&
lhs.deploymentTarget == rhs.deploymentTarget &&
lhs.settings == rhs.settings &&
lhs.configFiles == rhs.configFiles &&
lhs.sources == rhs.sources &&
@@ -211,12 +211,12 @@ extension Target: NamedJSONDictionaryConvertible {
throw SpecParsingError.unknownTargetPlatform(platformString)
}
if let string: String = jsonDictionary.json(atKeyPath: "platformVersion") {
platformVersion = try Version(string)
} else if let double: Double = jsonDictionary.json(atKeyPath: "platformVersion") {
platformVersion = try Version(double)
if let string: String = jsonDictionary.json(atKeyPath: "deploymentTarget") {
deploymentTarget = try Version(string)
} else if let double: Double = jsonDictionary.json(atKeyPath: "deploymentTarget") {
deploymentTarget = try Version(double)
} else {
platformVersion = nil
deploymentTarget = nil
}
settings = jsonDictionary.json(atKeyPath: "settings") ?? .empty
+4 -4
View File
@@ -17,8 +17,8 @@ extension ProjectSpec {
// apply custom platform version
for platform in Platform.all {
if let version = options.platformVersions.version(for: platform) {
buildSettings[platform.versionBuildSetting] = version.platformVersion
if let version = options.deploymentTargets.version(for: platform) {
buildSettings[platform.deploymentTargetSetting] = version.deploymentTarget
}
}
@@ -42,8 +42,8 @@ extension ProjectSpec {
}
// apply custom platform version
if let version = target.platformVersion {
buildSettings[target.platform.versionBuildSetting] = version.platformVersion
if let version = target.deploymentTarget {
buildSettings[target.platform.deploymentTargetSetting] = version.deploymentTarget
}
// Prevent setting presets from overrwriting settings in target xcconfig files
+2 -2
View File
@@ -5,7 +5,7 @@ options:
usesTabs: false
indentWidth: 2
tabWidth: 2
platformVersions:
deploymentTargets:
watchOS: 2.0
fileGroups:
- Configs
@@ -22,7 +22,7 @@ targets:
App_iOS:
type: application
platform: iOS
platformVersion: 10.0
deploymentTarget: 10.0
sources:
- StandaloneFiles/StandaloneAssets.xcassets
- path: App_iOS
@@ -165,8 +165,8 @@ func projectGeneratorTests() {
}
$0.it("generates platform version") {
let target = Target(name: "Target", type: .application, platform: .watchOS, platformVersion: "2.0")
let spec = ProjectSpec(basePath: "", name: "", targets: [target], options: .init(platformVersions: PlatformVersions(iOS: "10.0", watchOS: "3.0")))
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 pbxProject = try getPbxProj(spec)
+16 -16
View File
@@ -39,26 +39,26 @@ func projectSpecTests() {
}
}
$0.describe("Deployment Version") {
$0.describe("Deployment Target") {
$0.it("has correct build setting") {
try expect(Platform.iOS.versionBuildSetting) == "IPHONEOS_DEPLOYMENT_TARGET"
try expect(Platform.tvOS.versionBuildSetting) == "TVOS_DEPLOYMENT_TARGET"
try expect(Platform.watchOS.versionBuildSetting) == "WATCHOS_DEPLOYMENT_TARGET"
try expect(Platform.macOS.versionBuildSetting) == "MACOSX_DEPLOYMENT_TARGET"
try expect(Platform.iOS.deploymentTargetSetting) == "IPHONEOS_DEPLOYMENT_TARGET"
try expect(Platform.tvOS.deploymentTargetSetting) == "TVOS_DEPLOYMENT_TARGET"
try expect(Platform.watchOS.deploymentTargetSetting) == "WATCHOS_DEPLOYMENT_TARGET"
try expect(Platform.macOS.deploymentTargetSetting) == "MACOSX_DEPLOYMENT_TARGET"
}
$0.it("parses versions correctly") {
try expect(Version("2").platformVersion) == "2.0"
try expect(Version("2.0").platformVersion) == "2.0"
try expect(Version("2.1").platformVersion) == "2.1"
try expect(Version("2.1.0").platformVersion) == "2.1"
try expect(Version("2.12.0").platformVersion) == "2.12"
try expect(Version("2.1.2").platformVersion) == "2.1.2"
try expect(Version("2.0.2").platformVersion) == "2.0.2"
try expect(Version(2).platformVersion) == "2.0"
try expect(Version(2.0).platformVersion) == "2.0"
try expect(Version(2.1).platformVersion) == "2.1"
$0.it("parses version correctly") {
try expect(Version("2").deploymentTarget) == "2.0"
try expect(Version("2.0").deploymentTarget) == "2.0"
try expect(Version("2.1").deploymentTarget) == "2.1"
try expect(Version("2.1.0").deploymentTarget) == "2.1"
try expect(Version("2.12.0").deploymentTarget) == "2.12"
try expect(Version("2.1.2").deploymentTarget) == "2.1.2"
try expect(Version("2.0.2").deploymentTarget) == "2.0.2"
try expect(Version(2).deploymentTarget) == "2.0"
try expect(Version(2.0).deploymentTarget) == "2.0"
try expect(Version(2.1).deploymentTarget) == "2.1"
}
}
@@ -230,7 +230,7 @@ func specLoadingTests() {
createIntermediateGroups: true,
bundleIdPrefix: "com.test",
developmentLanguage: "ja",
platformVersions: PlatformVersions(
deploymentTargets: DeploymentTargets(
iOS: "11.1",
tvOS: "10.0",
watchOS: "3.0",
@@ -241,7 +241,7 @@ func specLoadingTests() {
"bundleIdPrefix": "com.test",
"createIntermediateGroups": true,
"developmentLanguage": "ja",
"platformVersions": ["iOS": 11.1, "tvOS": 10.0, "watchOS": "3", "macOS": "10.12.1" ]
"deploymentTargets": ["iOS": 11.1, "tvOS": 10.0, "watchOS": "3", "macOS": "10.12.1" ]
]]
let parsedSpec = try getProjectSpec(dictionary)
try expect(parsedSpec) == expected