From 520db0eb08efeafe285804db4d91128315ba7f2e Mon Sep 17 00:00:00 2001 From: ainopara Date: Sun, 3 Feb 2019 20:52:36 +0800 Subject: [PATCH 1/2] Make multi platform targets parse deployment target per platform. --- CHANGELOG.md | 1 + Docs/ProjectSpec.md | 4 ++++ Sources/ProjectSpec/Target.swift | 3 +++ Tests/XcodeGenKitTests/SpecLoadingTests.swift | 3 +++ 4 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b581d2e6..703be4cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ #### Added - Added `missingConfigFiles` to `options.disabledValidations` to optionally skip checking for the existence of config files. - Added ability to automatically include Carthage related dependencies via `includeRelated: true` [#506](https://github.com/yonaskolb/XcodeGen/pull/506) @rpassis +- Added ability to customize deployment target for Multi Platform targets. [#510](https://github.com/yonaskolb/XcodeGen/pull/510) @ainopara #### Fixed - Sources outside a project spec's directory will be correctly referenced as relative paths in the project file. [#524](https://github.com/yonaskolb/XcodeGen/pull/524) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 7ac7c672..4347b750 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -256,6 +256,7 @@ This will provide default build settings for a certain platform. It can be any o **Multi Platform targets** You can also specify an array of platforms. This will generate a target for each platform. +If deployment target is specified, it will be used for these targets. Or else deplyment target specified in [Options](#options) will be used. If you reference the string `$platform` anywhere within the target spec, that will be replaced with the platform. The generated targets by default will have a suffix of `_$platform` applied, you can change this by specifying a `platformSuffix` or `platformPrefix`. @@ -267,6 +268,9 @@ targets: MyFramework: sources: MyFramework platform: [iOS, tvOS] + deploymentTarget: + iOS: 9.0 + tvOS: 10.0 type: framework settings: base: diff --git a/Sources/ProjectSpec/Target.swift b/Sources/ProjectSpec/Target.swift index c9f4d572..5beb82b2 100644 --- a/Sources/ProjectSpec/Target.swift +++ b/Sources/ProjectSpec/Target.swift @@ -194,6 +194,9 @@ extension Target { } platformTarget["productName"] = targetName platformTarget["settings"] = settings + if let deploymentTargets = target["deploymentTarget"] as? [String: Any] { + platformTarget["deploymentTarget"] = deploymentTargets[platform] + } crossPlatformTargets[newTargetName] = platformTarget } } else { diff --git a/Tests/XcodeGenKitTests/SpecLoadingTests.swift b/Tests/XcodeGenKitTests/SpecLoadingTests.swift index c6d199eb..b4cdd4b9 100644 --- a/Tests/XcodeGenKitTests/SpecLoadingTests.swift +++ b/Tests/XcodeGenKitTests/SpecLoadingTests.swift @@ -310,6 +310,7 @@ class SpecLoadingTests: XCTestCase { $0.it("parses cross platform targets") { let targetDictionary: [String: Any] = [ "platform": ["iOS", "tvOS"], + "deploymentTarget": ["iOS": 9.0, "tvOS": "10.0"], "type": "framework", "sources": ["Framework", "Framework $platform"], "settings": ["SETTING": "value_$platform"], @@ -323,6 +324,8 @@ class SpecLoadingTests: XCTestCase { target_tvOS.sources = ["Framework", "Framework tvOS"] target_iOS.settings = ["PRODUCT_NAME": "Framework", "SETTING": "value_iOS"] target_tvOS.settings = ["PRODUCT_NAME": "Framework", "SETTING": "value_tvOS"] + target_iOS.deploymentTarget = Version(major: 9, minor: 0, patch: 0) + target_tvOS.deploymentTarget = Version(major: 10, minor: 0, patch: 0) try expect(project.targets.count) == 2 try expect(project.targets) == [target_iOS, target_tvOS] From 9fb507415bb1a7045ce59af60e169fa8424265d6 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Thu, 14 Mar 2019 21:09:08 +0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-Authored-By: ainopara --- CHANGELOG.md | 2 +- Docs/ProjectSpec.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 703be4cb..5da2cf1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ #### Added - Added `missingConfigFiles` to `options.disabledValidations` to optionally skip checking for the existence of config files. - Added ability to automatically include Carthage related dependencies via `includeRelated: true` [#506](https://github.com/yonaskolb/XcodeGen/pull/506) @rpassis -- Added ability to customize deployment target for Multi Platform targets. [#510](https://github.com/yonaskolb/XcodeGen/pull/510) @ainopara +- Added ability to define a per-platform `deploymentTarget` for Multi-Platform targets. [#510](https://github.com/yonaskolb/XcodeGen/pull/510) @ainopara #### Fixed - Sources outside a project spec's directory will be correctly referenced as relative paths in the project file. [#524](https://github.com/yonaskolb/XcodeGen/pull/524) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 4347b750..40168376 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -256,7 +256,7 @@ This will provide default build settings for a certain platform. It can be any o **Multi Platform targets** You can also specify an array of platforms. This will generate a target for each platform. -If deployment target is specified, it will be used for these targets. Or else deplyment target specified in [Options](#options) will be used. +If `deploymenTarget` is specified for a multi platform target, it can have different values per platform similar to how it's defined in [Options](#options). See below for an example. If you reference the string `$platform` anywhere within the target spec, that will be replaced with the platform. The generated targets by default will have a suffix of `_$platform` applied, you can change this by specifying a `platformSuffix` or `platformPrefix`.