Skip to content

Commit bd8502f

Browse files
authored
Merge pull request #2 from krbarnes/master
Swift 4.1 and Xcode 9.3 updates
2 parents e46eb56 + 0449453 commit bd8502f

File tree

14 files changed

+41
-27
lines changed

14 files changed

+41
-27
lines changed

Sources/XcodeProject/Archiving/PBXPListArchiver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ final class ObjectVisitor {
149149
}
150150

151151
func objects<T: PBXObject>() -> [T] {
152-
return objectMap.flatMap { return $0.value as? T }
152+
return objectMap.compactMap { return $0.value as? T }
153153
}
154154
}
155155

Sources/XcodeProject/Objects+Extensions/PBXGroup+FolderSync.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public extension PBXGroup {
103103

104104
private func addMissingFiles(recursive: Bool, target: PBXTarget?) {
105105
guard let url = self.url else { return }
106-
let childPathItems: [(String, PBXReference)] = children.flatMap {
106+
let childPathItems: [(String, PBXReference)] = children.compactMap {
107107
guard let childURL = $0.url else { return nil }
108108
return (childURL.path, $0)
109109
}
@@ -114,7 +114,7 @@ public extension PBXGroup {
114114
return childPathMap[$0.path] == nil
115115
}
116116
let files = missing.filter { !$0.hasDirectoryPath }
117-
let additionalFiles = files.flatMap {
117+
let additionalFiles = files.compactMap {
118118
add(file: $0)
119119
}
120120

@@ -129,7 +129,7 @@ public extension PBXGroup {
129129
directories.forEach {
130130
addGroup(pathComponent: $0.lastPathComponent)
131131
}
132-
children.flatMap { $0 as? PBXGroup }.forEach {
132+
children.compactMap { $0 as? PBXGroup }.forEach {
133133
$0.addMissingFiles(recursive: recursive, target: target)
134134
}
135135
}

Sources/XcodeProject/Objects+Extensions/PBXGroup+Sorting.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public extension PBXGroup {
1515

1616
func sort(recursive: Bool, by areInIncreasingOrder: (PBXReference, PBXReference) -> Bool) {
1717
if recursive {
18-
children.flatMap { return $0 as? PBXGroup }.forEach {
18+
children.compactMap { return $0 as? PBXGroup }.forEach {
1919
$0.sort(recursive: recursive, by: areInIncreasingOrder)
2020
}
2121
}

Sources/XcodeProject/Objects/Build Phases/PBXBuildPhase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class PBXBuildPhase: PBXObject {
5858
fatalError()
5959
}
6060
self._name = plist["name"]?.string
61-
self.files = files.flatMap {
61+
self.files = files.compactMap {
6262
let file: PBXBuildFile? = objectCache.object(for: PBXObject.ID(rawValue: $0))
6363
return file
6464
}

Sources/XcodeProject/Objects/PBXObject+ID.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extension PBXObject {
2727
}
2828

2929
static func ids(from strings: [String]?) -> [PBXObject.ID]? {
30-
return strings?.flatMap({ return PBXObject.ID(rawValue: $0) })
30+
return strings?.compactMap { return PBXObject.ID(rawValue: $0) }
3131
}
3232

3333
private static var generator: IDGenerator = IDGenerator()

Sources/XcodeProject/Objects/PBXProject.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public final class PBXProject: PBXObject, PBXContainer {
9797
self.projectDirPath = projectDirPath
9898

9999
if let projectReferences = plist["projectReferences"]?.object as? [[String: String]] {
100-
self.projectReferences = projectReferences.flatMap { projectReference in
100+
self.projectReferences = projectReferences.compactMap { projectReference in
101101
guard
102102
let projectRefId = PBXObject.ID(rawValue: projectReference["ProjectRef"]),
103103
let projectRef = objectCache.object(for: projectRefId) as? PBXFileReference,
@@ -112,7 +112,7 @@ public final class PBXProject: PBXObject, PBXContainer {
112112
}
113113

114114
self.projectRoot = projectRoot
115-
self.targets = targets.flatMap {
115+
self.targets = targets.compactMap {
116116
let target: PBXTarget? = objectCache.object(for: PBXObject.ID(rawValue: $0))
117117
return target
118118
}

Sources/XcodeProject/Objects/References/PBXGroup.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class PBXGroup: PBXReference {
3131

3232
override func update(with plist: PropertyList, objectCache: ObjectCache) {
3333
super.update(with: plist, objectCache: objectCache)
34-
self.children = plist["children"]?.array?.map { return PBXObject.ID(rawValue: $0) }.flatMap { objectCache.object(for: $0) as? PBXReference } ?? []
34+
self.children = plist["children"]?.array?.map { return PBXObject.ID(rawValue: $0) }.compactMap { objectCache.object(for: $0) as? PBXReference } ?? []
3535
}
3636

3737
override func visit(_ visitor: ObjectVisitor) {

Sources/XcodeProject/Objects/Targets/PBXTarget.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ public class PBXTarget: PBXObject, PBXContainer {
7979
self.productName = productName
8080
self.productReference = objectCache.object(for: PBXObject.ID(rawValue: plist["productReference"]?.string)) as? PBXFileReference
8181
self.buildConfigurationList = buildConfigurationList
82-
self.buildPhases = buildPhases.flatMap {
82+
self.buildPhases = buildPhases.compactMap {
8383
return objectCache.object(for: PBXObject.ID(rawValue: $0)) as? PBXBuildPhase
8484
}
85-
self.buildRules = plist["buildRules"]?.array?.flatMap {
85+
self.buildRules = plist["buildRules"]?.array?.compactMap {
8686
return objectCache.object(for: PBXObject.ID(rawValue: $0)) as? PBXBuildRule
8787
}
88-
self.dependencies = dependencies.flatMap {
88+
self.dependencies = dependencies.compactMap {
8989
return objectCache.object(for: PBXObject.ID(rawValue: $0)) as? PBXTargetDependency
9090
}
9191
}

Sources/XcodeProject/Objects/XCConfigurationList.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class XCConfigurationList: PBXObject {
4545
fatalError()
4646
}
4747

48-
self.buildConfigurations = buildConfigurations.flatMap { objectCache.object(for: $0) }
48+
self.buildConfigurations = buildConfigurations.compactMap { objectCache.object(for: $0) }
4949
self.defaultConfigurationIsVisible = Int(defaultConfigurationIsVisibleString) != 0
5050
self.defaultConfigurationName = plist["defaultConfigurationName"]?.string
5151
}

Sources/XcodeProject/Workspace.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010

1111
public protocol WorkspaceReference: class {
12-
weak var parent: WorkspaceReference? { get }
12+
var parent: WorkspaceReference? { get }
1313
var referenceURL: URL? { get }
1414
}
1515

@@ -100,7 +100,7 @@ public final class Workspace: WorkspaceReference {
100100

101101
let document = try XMLDocument(data: data, options: [])
102102
guard let children = document.rootElement()?.children as? [XMLElement] else { throw Error.invalid }
103-
self.references = children.flatMap {
103+
self.references = children.compactMap {
104104
childOf(element: $0, parent: self)
105105
}
106106
}
@@ -116,7 +116,7 @@ public final class Workspace: WorkspaceReference {
116116
guard let location = element.attribute(forName: "location")?.objectValue as? String else { return nil }
117117
guard let name = element.attribute(forName: "name")?.objectValue as? String else { return nil }
118118
let group = GroupReference(location: location, name: name, children: [], parent: parent)
119-
group.children = childrenElements.flatMap {
119+
group.children = childrenElements.compactMap {
120120
childOf(element: $0, parent: group)
121121
}
122122
return group

0 commit comments

Comments
 (0)