Skip to content

Commit

Permalink
Merge pull request #541 from yonaskolb/fix/multi-platform_templates
Browse files Browse the repository at this point in the history
Fix multi-platform target templates
  • Loading branch information
yonaskolb authored Mar 24, 2019
2 parents 72d24ff + c9de565 commit 2643312
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions Sources/ProjectSpec/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
48 changes: 48 additions & 0 deletions Tests/XcodeGenKitTests/SpecLoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Expand Down

0 comments on commit 2643312

Please sign in to comment.