Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 988afa0

Browse files
author
Dale Myers
authored
Sanitize the ends of folder source paths (yonaskolb#1341)
* Sanitize the ends of folder source paths Setting the source: `/foo/bar` is _sometimes_ different from `/foo/bar/` even if `bar` is a folder in both cases. The result of this is that we often run into a race condition where we have two objects with the same hash but different properties. This fixes yonaskolb#1339 and yonaskolb#1131. * Update CHANGELOG.md * Update TargetSource.swift * Update TargetSource.swift * Update TargetSource.swift
1 parent 5a34c48 commit 988afa0

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Added support for shared breakpoints #177 @alexruperez @myihsan
88

9+
### Fixed
10+
11+
- Fix case where source paths may not be deduplicated correctly resulting in duplicate groups and/or a crash in running Xcodegen #1341 @dalemyers
12+
913
## 2.34.0
1014

1115
### Changed

Sources/ProjectSpec/TargetSource.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ import PathKit
44

55
public struct TargetSource: Equatable {
66
public static let optionalDefault = false
7-
8-
public var path: String
7+
8+
public var path: String {
9+
didSet {
10+
path = (path as NSString).standardizingPath
11+
}
12+
}
13+
914
public var name: String?
1015
public var group: String?
1116
public var compilerFlags: [String]
@@ -48,7 +53,7 @@ public struct TargetSource: Equatable {
4853
attributes: [String] = [],
4954
resourceTags: [String] = []
5055
) {
51-
self.path = path
56+
self.path = (path as NSString).standardizingPath
5257
self.name = name
5358
self.group = group
5459
self.compilerFlags = compilerFlags
@@ -83,6 +88,7 @@ extension TargetSource: JSONObjectConvertible {
8388

8489
public init(jsonDictionary: JSONDictionary) throws {
8590
path = try jsonDictionary.json(atKeyPath: "path")
91+
path = (path as NSString).standardizingPath // Done in two steps as the compiler can't figure out the types otherwise
8692
name = jsonDictionary.json(atKeyPath: "name")
8793
group = jsonDictionary.json(atKeyPath: "group")
8894

0 commit comments

Comments
 (0)