Make multi platform targets parse deployment target per platform.

This commit is contained in:
ainopara 2019-02-03 20:52:36 +08:00
parent d85ca0d84e
commit 520db0eb08
4 changed files with 11 additions and 0 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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 {

View File

@ -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]