Merge pull request #541 from yonaskolb/fix/multi-platform_templates

Fix multi-platform target templates
This commit is contained in:
Yonas Kolb 2019-03-24 17:48:26 +11:00 committed by GitHub
commit 2643312519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 0 deletions

View File

@ -18,6 +18,7 @@
- Fixed error when `optional` path is missing [#527](https://github.com/yonaskolb/XcodeGen/pull/527) @yonaskolb
- Fixed excludes within included spec [#535](https://github.com/yonaskolb/XcodeGen/pull/535) @yonaskolb
- Fixed paths in target templates within included files not being relative [#537](https://github.com/yonaskolb/XcodeGen/pull/537) @yonaskolb
- Fix multi-platform target templates [#541](https://github.com/yonaskolb/XcodeGen/pull/541) @yonaskolb
## 2.2.0

View File

@ -171,8 +171,13 @@ extension Project {
static func resolveProject(jsonDictionary: JSONDictionary) throws -> JSONDictionary {
var jsonDictionary = jsonDictionary
// resolve multiple times so that we support both multi-platform templates,
// as well as platform specific templates in multi-platform targets
jsonDictionary = try Target.resolveMultiplatformTargets(jsonDictionary: jsonDictionary)
jsonDictionary = try Target.resolveTargetTemplates(jsonDictionary: jsonDictionary)
jsonDictionary = try Target.resolveMultiplatformTargets(jsonDictionary: jsonDictionary)
return jsonDictionary
}
}

View File

@ -590,6 +590,54 @@ class SpecLoadingTests: XCTestCase {
try expect(target.sources) == ["nestedTemplateSource2", "nestedTemplateSource1", "templateSource", "targetSource"] // merges array in order
try expect(target.configFiles["debug"]) == "Configs/Framework/debug.xcconfig" // replaces $target_name
}
$0.it("parses cross platform target templates") {
let project = try getProjectSpec([
"targets": [
"Framework": [
"type": "framework",
"templates": ["temp"],
]
],
"targetTemplates": [
"temp": [
"platform": ["iOS", "tvOS"],
]
],
])
let iOSTarget = project.targets.first { $0.platform == .iOS }
let tvOSTarget = project.targets.first { $0.platform == .tvOS }
try expect(iOSTarget?.type) == .framework
try expect(tvOSTarget?.type) == .framework
}
$0.it("parses platform specific templates") {
let project = try getProjectSpec([
"targets": [
"Framework": [
"type": "framework",
"platform": ["iOS", "tvOS"],
"templates": ["$platform"],
]
],
"targetTemplates": [
"iOS": [
"sources": "A",
],
"tvOS": [
"sources": "B",
]
],
])
let iOSTarget = project.targets.first { $0.platform == .iOS }
let tvOSTarget = project.targets.first { $0.platform == .tvOS }
try expect(iOSTarget?.sources) == ["A"]
try expect(tvOSTarget?.sources) == ["B"]
}
$0.it("parses aggregate targets") {
let dictionary: [String: Any] = [