Skip to content

Commit

Permalink
Merge pull request #542 from yonaskolb/fix/mixed_relative_paths
Browse files Browse the repository at this point in the history
Fix included relative sources in mixed arrays
  • Loading branch information
yonaskolb authored Mar 24, 2019
2 parents 2643312 + 3289fdc commit 716b30c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- 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
- Fixed sources in an included target not being relative when the sources are mix of string and dictionaries [#542](https://github.com/yonaskolb/XcodeGen/pull/542) @yonaskolb

## 2.2.0

Expand Down
20 changes: 16 additions & 4 deletions Sources/ProjectSpec/PathContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ extension Array where Element == PathProperty {
case .string(let key):
if let source = result[key] as? String {
result[key] = (path + source).string
} else if let source = result[key] as? [String] {
result[key] = source.map { (path + $0).string }
} else if let source = result[key] as? [Any] {
result[key] = source.map { any -> Any in
if let string = any as? String {
return (path + string).string
} else {
return any
}
}
} else if let source = result[key] as? [String: String] {
result[key] = source.mapValues { (path + $0).string }
}
Expand All @@ -37,8 +43,14 @@ extension Array where Element == PathProperty {
case .object(let key, let pathProperties):
if let source = result[key] as? JSONDictionary {
result[key] = pathProperties.resolvingPaths(in: source, relativeTo: path)
} else if let source = result[key] as? [JSONDictionary] {
result[key] = source.map { pathProperties.resolvingPaths(in: $0, relativeTo: path) }
} else if let source = result[key] as? [Any] {
result[key] = source.map { any -> Any in
if let dictionary = any as? JSONDictionary {
return pathProperties.resolvingPaths(in: dictionary, relativeTo: path)
} else {
return any
}
}
} else if let source = result[key] as? [String: JSONDictionary] {
result[key] = source.mapValues { pathProperties.resolvingPaths(in: $0, relativeTo: path) }
}
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/paths_test/included_paths_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ targets:
configFiles:
Config: config
sources:
- simplesource
- path: source
excludes: [file]
dependencies:
Expand Down
5 changes: 4 additions & 1 deletion Tests/XcodeGenKitTests/SpecLoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ class SpecLoadingTests: XCTestCase {
type: .application,
platform: .tvOS,
configFiles: ["Config": "paths_test/config"],
sources: [TargetSource(path: "paths_test/source", excludes: ["file"])],
sources: [
"paths_test/simplesource",
TargetSource(path: "paths_test/source", excludes: ["file"]),
],
dependencies: [Dependency(type: .framework, reference: "paths_test/Framework")],
info: Plist(path: "paths_test/info"),
entitlements: Plist(path: "paths_test/entitlements"),
Expand Down

0 comments on commit 716b30c

Please sign in to comment.