Skip to content

Commit 1e761a5

Browse files
committed
2.11.1
1 parent 8d05508 commit 1e761a5

File tree

3 files changed

+4
-107
lines changed

3 files changed

+4
-107
lines changed

Example/XcodeEdit-Example/main.swift

Lines changed: 1 addition & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -29,112 +29,7 @@ for obj in proj.allObjects.objects.values {
2929
}
3030

3131
// Write out a new pbxproj file
32-
//try! proj.write(to: xcodeproj, format: .plist(.openStep))
33-
34-
35-
public struct Xcodeproj {
36-
static public let supportedExtensions: Set<String> = ["xcodeproj"]
37-
38-
private let projectFile: XCProjectFile
39-
40-
public let developmentRegion: String
41-
public let knownAssetTags: [String]?
42-
43-
public init(url: URL, warning: (String) -> Void) throws {
44-
// try Xcodeproj.throwIfUnsupportedExtension(url)
45-
let projectFile: XCProjectFile
46-
47-
// Parse project file
48-
do {
49-
do {
50-
projectFile = try XCProjectFile(xcodeprojURL: url, ignoreReferenceErrors: false)
51-
}
52-
catch let error as ProjectFileError {
53-
warning(error.localizedDescription)
54-
55-
projectFile = try XCProjectFile(xcodeprojURL: url, ignoreReferenceErrors: true)
56-
}
57-
}
58-
catch {
59-
fatalError("Project file at '\(url)' could not be parsed, is this a valid Xcode project file ending in *.xcodeproj?\n\(error.localizedDescription)")
60-
}
61-
62-
self.projectFile = projectFile
63-
self.developmentRegion = projectFile.project.developmentRegion
64-
self.knownAssetTags = projectFile.project.knownAssetTags
65-
}
66-
67-
public var allTargets: [PBXTarget] {
68-
projectFile.project.targets.compactMap { $0.value }
69-
}
70-
71-
private func findTarget(name: String) throws -> PBXTarget {
72-
// Look for target in project file
73-
let allTargets = projectFile.project.targets.compactMap { $0.value }
74-
guard let target = allTargets.filter({ $0.name == name }).first else {
75-
let availableTargets = allTargets.compactMap { $0.name }.joined(separator: ", ")
76-
fatalError("Target '\(name)' not found in project file, available targets are: \(availableTargets)")
77-
}
78-
79-
return target
80-
}
81-
82-
public func resourcePaths(forTarget targetName: String) throws -> [Path] {
83-
let target = try findTarget(name: targetName)
84-
85-
let resourcesFileRefs = target.buildPhases
86-
.compactMap { $0.value as? PBXResourcesBuildPhase }
87-
.flatMap { $0.files }
88-
.compactMap { $0.value?.fileRef }
89-
90-
let fileRefPaths = resourcesFileRefs
91-
.compactMap { $0.value as? PBXFileReference }
92-
.compactMap { $0.fullPath }
93-
94-
let variantGroupPaths = resourcesFileRefs
95-
.compactMap { $0.value as? PBXVariantGroup }
96-
.flatMap { $0.fileRefs }
97-
.compactMap { $0.value?.fullPath }
98-
99-
return fileRefPaths + variantGroupPaths
100-
}
101-
102-
public func buildConfigurations(forTarget targetName: String) throws -> [XCBuildConfiguration] {
103-
let target = try findTarget(name: targetName)
104-
105-
guard let buildConfigurationList = target.buildConfigurationList.value else { return [] }
106-
107-
let buildConfigurations = buildConfigurationList.buildConfigurations
108-
.compactMap { $0.value }
109-
110-
return buildConfigurations
111-
}
112-
}
113-
114-
extension PBXReference {
115-
func fileSystemSynchronizedGroups(path: URL) -> [(URL, PBXFileSystemSynchronizedRootGroup)] {
116-
if let root = self as? PBXFileSystemSynchronizedRootGroup {
117-
let newPath = root.path.map { path.appending(path: $0) } ?? path
118-
return [(newPath, root)]
119-
} else if let group = self as? PBXGroup {
120-
let newPath = group.path.map { path.appending(path: $0) } ?? path
121-
122-
let children = group.children.compactMap(\.value)
123-
124-
return children.flatMap { $0.fileSystemSynchronizedGroups(path: newPath) }
125-
126-
} else {
127-
return []
128-
}
129-
}
130-
}
131-
132-
133-
let the = try Xcodeproj(url: xcodeproj, warning: { fatalError($0)})
134-
135-
print(proj.project.mainGroup.value!.fileSystemSynchronizedGroups(path: xcodeproj.deletingLastPathComponent()))
136-
137-
print(try the.resourcePaths(forTarget: "RswiftUIAppClip"))
32+
try! proj.write(to: xcodeproj, format: .plist(.openStep))
13833

13934
let time = Date().timeIntervalSince(start)
14035
print("Timeinterval: \(time)")

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ try! proj.write(to: xcodeproj, format: PropertyListSerialization.PropertyListFor
3131
Releases
3232
--------
3333

34+
- 2.11.1 - 2024-11-03 - Make syncGroups property internal
3435
- 2.11.0 - 2024-11-03 - Add computed fullPath to PBXFileSystemSynchronizedRootGroup
3536
- 2.10.2 - 2024-09-24 - Add PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet
3637
- 2.10.1 - 2024-09-19 - Serialization fix for file system synchronized directories

Sources/XcodeEdit/PBXObject.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ public class PBXGroup : PBXReference {
382382
}
383383
}
384384

385-
public var syncRoots: [Reference<PBXFileSystemSynchronizedRootGroup>] {
385+
// Don't expose publicly, because this only exposes one level, not for all descentend sub groups.
386+
internal var syncRoots: [Reference<PBXFileSystemSynchronizedRootGroup>] {
386387
return _children.compactMap { childRef in
387388
guard let _ = childRef.value as? PBXFileSystemSynchronizedRootGroup else { return nil }
388389
return Reference(allObjects: childRef.allObjects, id: childRef.id)

0 commit comments

Comments
 (0)