Skip to content

Commit 19a06ab

Browse files
committed
Add build rules
1 parent e8bff87 commit 19a06ab

File tree

10 files changed

+1867
-10
lines changed

10 files changed

+1867
-10
lines changed

Sources/Isa.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public enum Isa: String, CaseIterable, CustomStringConvertible {
1414
case containerItemProxy = "PBXContainerItemProxy"
1515
case buildFile = "PBXBuildFile"
1616
case buildStyle = "PBXBuildStyle"
17+
case buildRule = "PBXBuildRule"
1718
case aggregateTarget = "PBXAggregateTarget"
1819
case nativeTarget = "PBXNativeTarget"
1920
case targetDependency = "PBXTargetDependency"
@@ -83,6 +84,7 @@ extension Isa {
8384
case .buildConfiguration: return XCBuildConfiguration.self
8485
case .remoteSwiftPackageReference: return XCRemoteSwiftPackageReference.self
8586
case .swiftPackageProductDependency: return XCSwiftPackageProductDependency.self
87+
case .buildRule: return PBXBuildRule.self
8688
}
8789
}
8890
}

Sources/PBXBuildRule.swift

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// PBXBuildRule.swift
3+
// XcodeProjKit
4+
//
5+
// Created by emarchand on 10/11/2022.
6+
// Copyright © 2022 AnOrgaName. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public class PBXBuildRule: PBXProjectItem {
12+
13+
public enum PBXKeys: PBXKey {
14+
case name
15+
case compilerSpec
16+
case dependencyFile
17+
case fileType
18+
case filePatterns
19+
case isEditable
20+
case runOncePerArchitecture
21+
case script
22+
}
23+
24+
#if LAZY
25+
public lazy var name: String = self.string(PBXKeys.name)
26+
public lazy var compilerSpec: String = self.string(PBXKeys.compilerSpec)
27+
public lazy var dependencyFile: String? = self.string(PBXKeys.dependencyFile)
28+
public lazy var fileType: String? = self.string(PBXKeys.fileType)
29+
public lazy var filePatterns: String? = self.string(PBXKeys.filePatterns)
30+
public lazy var isEditable: Bool = self.bool(PBXKeys.isEditable)
31+
public lazy var runOncePerArchitecture: String? = self.string(PBXKeys.runOncePerArchitecture)
32+
public lazy var script: String = self.string(PBXKeys.script)
33+
#else
34+
public var name: String { self.string(PBXKeys.name) }
35+
public var compilerSpec: String { self.string(PBXKeys.compilerSpec) }
36+
public var dependencyFile: String? { self.string(PBXKeys.dependencyFile) }
37+
public var fileType: String? { self.string(PBXKeys.fileType) }
38+
public var filePatterns: String? { self.string(PBXKeys.filePatterns) }
39+
public var isEditable: Bool { self.bool(PBXKeys.isEditable) }
40+
public var runOncePerArchitecture: String? { self.string(PBXKeys.runOncePerArchitecture) }
41+
public var script: String { self.string(PBXKeys.script) }
42+
#endif
43+
44+
// var inputFiles: Array
45+
// var outputFiles: Array
46+
// var outputFilesCompilerFlag: Array
47+
}

Sources/PBXBuildStyle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class PBXBuildStyle: PBXProjectItem {
1717
#if LAZY
1818
public lazy var buildSettings: [String: Any]? = dictionary(PBXKeys.buildSettings)
1919
#else
20-
public var buildSettings: [String: Any]? {
20+
public var buildSettings: [String: Any]? {
2121
get {
2222
dictionary(PBXKeys.buildSettings)
2323
}

Sources/PBXTarget.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public /* abstract */ class PBXTarget: PBXProjectItem, PBXBuildConfigurationList
1414
case name
1515
case productName
1616
case buildPhases
17+
case buildRules
1718
case buildConfigurationList
1819
case dependencies
1920
case packageProductDependencies
@@ -23,13 +24,15 @@ public /* abstract */ class PBXTarget: PBXProjectItem, PBXBuildConfigurationList
2324
public lazy var name: String = self.string(PBXKeys.name)
2425
public lazy var productName: String? = self.string(PBXKeys.productName)
2526
public lazy var buildPhases: [PBXBuildPhase] = self.objects(PBXKeys.buildPhases)
27+
public lazy var buildRules: [PBXBuildRule] = self.objects(PBXKeys.buildRules)
2628
public lazy var buildConfigurationList: XCConfigurationList? = self.object(PBXKeys.buildConfigurationList)
2729
public lazy var dependencies: [PBXTargetDependency] = self.objects(PBXKeys.dependencies)
2830
public lazy var packageProductDependencies: [XCSwiftPackageProductDependency] = self.objects(PBXKeys.packageProductDependencies) // swiftlint:disable:this line_length
2931
#else
3032
public var name: String { self.string(PBXKeys.name) }
3133
public var productName: String? { self.string(PBXKeys.productName) }
3234
public var buildPhases: [PBXBuildPhase] { self.objects(PBXKeys.buildPhases) }
35+
public var buildRules: [PBXBuildRule] { self.objects(PBXKeys.buildRules) }
3336
public var buildConfigurationList: XCConfigurationList? { self.object(PBXKeys.buildConfigurationList) }
3437
public var dependencies: [PBXTargetDependency] { self.objects(PBXKeys.dependencies) }
3538
public var packageProductDependencies: [XCSwiftPackageProductDependency] {self.objects(PBXKeys.packageProductDependencies) } // swiftlint:disable:this line_length

Sources/PropertyList.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ extension URL {
152152
var isStdOut: Bool {
153153
return self.isFileURL && self.path == "/dev/stdout"
154154
}
155-
}
155+
}

Sources/XcodeProj.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public class XcodeProj: PropertyList {
9090
if let result = extractProjetNameRegex.firstMatch(in: str, options: [], range: entireRange) {
9191
self.projectName = (str as NSString).substring(with: result.range)
9292
self.projectName = String(self.projectName[
93-
extractProjetName.endIndex..<self.projectName.index(self.projectName.endIndex, offsetBy: -1)])
93+
extractProjetName.endIndex..<self.projectName.index(self.projectName.endIndex, offsetBy: -1)]) // swiftlint:disable:this line_length
9494

9595
}
9696
}

Tests/XcodeProjKitParseTests.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ class XcodeProjKitParseTests: XCTestCase {
8383
func testyocelsius() {
8484
testParse("ok/yocelsius.09b4cb7.project")
8585
}
86-
86+
87+
func testoauthswift() {
88+
testParse("ok/oauthswift.project")
89+
}
90+
8791
func testplist() {
8892
testParse("ok/plist")
8993
}

0 commit comments

Comments
 (0)