Merge pull request #510 from ainopara/master

Make multi platform targets parse deployment target per platform.
This commit is contained in:
Yonas Kolb 2019-03-15 08:09:15 +11:00 committed by GitHub
commit e9e534ab2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#### Added #### Added
- Added `missingConfigFiles` to `options.disabledValidations` to optionally skip checking for the existence of config files. - 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 automatically include Carthage related dependencies via `includeRelated: true` [#506](https://github.com/yonaskolb/XcodeGen/pull/506) @rpassis
- Added ability to define a per-platform `deploymentTarget` for Multi-Platform targets. [#510](https://github.com/yonaskolb/XcodeGen/pull/510) @ainopara
#### Fixed #### 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) - 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** **Multi Platform targets**
You can also specify an array of platforms. This will generate a target for each platform. You can also specify an array of platforms. This will generate a target for each platform.
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. 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`. 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: MyFramework:
sources: MyFramework sources: MyFramework
platform: [iOS, tvOS] platform: [iOS, tvOS]
deploymentTarget:
iOS: 9.0
tvOS: 10.0
type: framework type: framework
settings: settings:
base: base:

View File

@ -194,6 +194,9 @@ extension Target {
} }
platformTarget["productName"] = targetName platformTarget["productName"] = targetName
platformTarget["settings"] = settings platformTarget["settings"] = settings
if let deploymentTargets = target["deploymentTarget"] as? [String: Any] {
platformTarget["deploymentTarget"] = deploymentTargets[platform]
}
crossPlatformTargets[newTargetName] = platformTarget crossPlatformTargets[newTargetName] = platformTarget
} }
} else { } else {

View File

@ -310,6 +310,7 @@ class SpecLoadingTests: XCTestCase {
$0.it("parses cross platform targets") { $0.it("parses cross platform targets") {
let targetDictionary: [String: Any] = [ let targetDictionary: [String: Any] = [
"platform": ["iOS", "tvOS"], "platform": ["iOS", "tvOS"],
"deploymentTarget": ["iOS": 9.0, "tvOS": "10.0"],
"type": "framework", "type": "framework",
"sources": ["Framework", "Framework $platform"], "sources": ["Framework", "Framework $platform"],
"settings": ["SETTING": "value_$platform"], "settings": ["SETTING": "value_$platform"],
@ -323,6 +324,8 @@ class SpecLoadingTests: XCTestCase {
target_tvOS.sources = ["Framework", "Framework tvOS"] target_tvOS.sources = ["Framework", "Framework tvOS"]
target_iOS.settings = ["PRODUCT_NAME": "Framework", "SETTING": "value_iOS"] target_iOS.settings = ["PRODUCT_NAME": "Framework", "SETTING": "value_iOS"]
target_tvOS.settings = ["PRODUCT_NAME": "Framework", "SETTING": "value_tvOS"] 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.count) == 2
try expect(project.targets) == [target_iOS, target_tvOS] try expect(project.targets) == [target_iOS, target_tvOS]