Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix included relative sources in mixed arrays #542

Merged
merged 1 commit into from
Mar 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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