Skip to content

Commit dbed726

Browse files
Updated PBX and Xcode classes to inherit from NSObject
1 parent 4ba9aa3 commit dbed726

18 files changed

+102
-71
lines changed

Sources/PBXProj/PBXProj.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Dispatch
1212

1313

1414
/// Class that represents an Xcode PBX Project file
15-
public class PBXProj: Codable {
15+
public class PBXProj: NSObject, Codable {
1616
internal enum CodingKeys: String, CodingKey {
1717
case archiveVersion
1818
case objectVersion
@@ -106,6 +106,8 @@ public class PBXProj: Codable {
106106
self.rootObject = "ROOT_REFERENCE"
107107
self.objects = PBXObjects()
108108

109+
super.init()
110+
109111
self.objects.proj = self
110112

111113
if objectVersion >= 50 { self.idGenFunc = generateNewUUIDReference }
@@ -186,6 +188,8 @@ public class PBXProj: Codable {
186188
self.rootObject = try container.decode(PBXReference.self, forKey: .rootObject)
187189
self.objects = try container.decode(PBXObjects.self, forKey: .objects)
188190

191+
super.init()
192+
189193
self.objects.proj = self
190194

191195
self.project = self.objects.object(withReference: self.rootObject, asType: PBXProject.self)!

Sources/PBXProj/objects/PBXObject.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/// A base class for all PBX Objects
11-
public class PBXObject: Codable {
11+
public class PBXObject: NSObject, Codable {
1212

1313
/// Base PBX Object Coding Keys
1414
internal enum ObjectCodingKeys: String, CodingKey {
@@ -43,13 +43,15 @@ public class PBXObject: Codable {
4343
internal init(id: PBXReference, type: PBXObjectType) {
4444
self.id = id
4545
self.type = type
46+
super.init()
4647
}
4748

4849
public required init(from decoder: Decoder) throws {
4950
let container = try decoder.container(keyedBy: ObjectCodingKeys.self)
5051

5152
self.id = try container.decode(PBXReference.self, forKey: .id)
5253
self.type = try container.decode(PBXObjectType.self, forKey: .type)
54+
super.init()
5355
}
5456

5557
public func encode(to encoder: Encoder) throws {

Sources/PBXProj/objects/PBXObjects.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
import AdvancedCodableHelpers
1010
import RawRepresentableHelpers
1111

12-
public final class PBXObjects: Codable {
12+
public final class PBXObjects: NSObject, Codable {
1313
public enum ObjectError: Error {
1414
case objectNotFound(PBXReference)
1515
case castingFailure(PBXObject, Any.Type)
@@ -34,12 +34,17 @@ public final class PBXObjects: Codable {
3434
public var containerProxyItems: [PBXContainerItemProxy] { return self.of(type: PBXContainerItemProxy.self) }
3535

3636
/// Create new instance of PBXObjects
37-
internal init() { }
37+
internal override init() {
38+
super.init()
39+
}
3840
/// Create new instance of PBXObjects
3941
///
4042
/// - Parameter objects: The objects to initialize with
4143
fileprivate init(_ objects: [PBXObject]) {
4244
self.objects = objects
45+
46+
super.init()
47+
4348
for o in self.objects {
4449
o.objectList = self
4550
}

Sources/PBXProj/objects/attributes/PBXProductType.swift

100644100755
File mode changed.

Sources/PBXProj/objects/buildPhases/PBXShellScriptBuildPhase.swift

100644100755
File mode changed.

Sources/XcodeProj/XCWorkspace/objects/XCSharedData.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
import CustomCoders
1010
import AdvancedCodableHelpers
1111

12-
public final class XCSharedData {
12+
public final class XCSharedData: NSObject {
1313

1414
private static let IDE_WORKSPACE_CHECKS_FILE_NAME: String = "IDEWorkspaceChecks.plist"
1515
private static let WORKSPACE_SETTINGS_FILE_NAME: String = "WorkspaceSettings.xcsettings"
@@ -25,13 +25,16 @@ public final class XCSharedData {
2525
didSet { self.hasWorkspaceSettingsChanged = true }
2626
}
2727

28-
public init() {
28+
public override var debugDescription: String { return "XCSharedData(\(self.schemes.debugDescription))" }
29+
30+
public override init() {
2931
self.schemes = XCSchemes()
3032
self.ideWorkspaceChecks = [:]
3133
self.workspaceSettings = [:]
3234

3335
// Setup defaults
3436
self.ideWorkspaceChecks["IDEDidComputeMac32BitWarning"] = true
37+
super.init()
3538

3639
}
3740

@@ -74,6 +77,7 @@ public final class XCSharedData {
7477

7578
self.schemes = try XCSchemes(from: url.appendingDirComponent(XCSchemes.SCHEMES_FOLDER),
7679
usingFSProvider: provider)
80+
super.init()
7781
}
7882

7983
/// Get all save actions that are needed
@@ -154,7 +158,3 @@ public final class XCSharedData {
154158

155159
}
156160
}
157-
158-
extension XCSharedData: CustomDebugStringConvertible {
159-
public var debugDescription: String { return "XCSharedData(\(self.schemes.debugDescription))" }
160-
}

Sources/XcodeProj/XCWorkspace/objects/XCShemes.swift

+14-14
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fileprivate extension String {
2020
}
2121
}
2222

23-
public final class XCSchemes {
23+
public final class XCSchemes: NSObject {
2424

2525
public static let SCHEMES_FOLDER: String = "xcschemes"
2626
private static let MANAGEMENT_SETTINGS_FILE: String = "xcschememanagement.plist"
@@ -35,13 +35,24 @@ public final class XCSchemes {
3535
didSet { self.hasProjectSchemesChanged = true }
3636
}
3737

38+
public override var debugDescription: String {
39+
var rtn: String = "XCSchemes["
40+
for (i, scheme) in self.projectSchemes.keys.enumerated() {
41+
if i > 0 { rtn += ", " }
42+
rtn += "\(scheme): \(self.projectSchemes[scheme]!)"
43+
}
44+
rtn += "]"
45+
return rtn
46+
}
47+
3848

3949
/// Create new empty instance of an empty Scheme List
40-
public init() {
50+
public override init() {
4151
self.hasManagementChanged = true
4252
self.management = [:]
4353
self.projectSchemes = [:]
4454
self.hasProjectSchemesChanged = true
55+
super.init()
4556
}
4657

4758
/// Create new insatance of a Scheme List
@@ -84,6 +95,7 @@ public final class XCSchemes {
8495
} else {
8596
throw XcodeFileSystemProviderErrors.invalidResults
8697
}
98+
super.init()
8799

88100
}
89101

@@ -179,15 +191,3 @@ public final class XCSchemes {
179191

180192
}
181193
}
182-
183-
extension XCSchemes: CustomDebugStringConvertible {
184-
public var debugDescription: String {
185-
var rtn: String = "XCSchemes["
186-
for (i, scheme) in self.projectSchemes.keys.enumerated() {
187-
if i > 0 { rtn += ", " }
188-
rtn += "\(scheme): \(self.projectSchemes[scheme]!)"
189-
}
190-
rtn += "]"
191-
return rtn
192-
}
193-
}

Sources/XcodeProj/XCWorkspace/objects/XCUserData.swift

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public final class XCUserData {
10+
public final class XCUserData: NSObject {
1111

1212
public enum Error: Swift.Error {
1313
//case urlNotFileBased(URL)
@@ -25,6 +25,10 @@ public final class XCUserData {
2525
/// The debugging data
2626
public let debugger: XCDebugger
2727

28+
public override var debugDescription: String {
29+
return "XCUserData(\(self.user): \(self.schemes.debugDescription))"
30+
}
31+
2832
/// Create new instance of a User Data from file
2933
///
3034
/// - Parameters:
@@ -53,6 +57,7 @@ public final class XCUserData {
5357
// Load Debugger info
5458
self.debugger = try XCDebugger(from: url.appendingDirComponent(XCDebugger.DEBUGGER_FOLDER_NAME),
5559
usingFSProvider: provider)
60+
super.init()
5661

5762
}
5863

@@ -96,9 +101,3 @@ public final class XCUserData {
96101

97102
}
98103
}
99-
100-
extension XCUserData: CustomDebugStringConvertible {
101-
public var debugDescription: String {
102-
return "XCUserData(\(self.user): \(self.schemes.debugDescription))"
103-
}
104-
}

Sources/XcodeProj/XCWorkspace/objects/XCUserDataList.swift

+15-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/// Stores all the user data
11-
public final class XCUserDataList {
11+
public final class XCUserDataList: NSObject {
1212

1313
public enum Error: Swift.Error {
1414
//case urlNotFileBased(URL)
@@ -25,8 +25,20 @@ public final class XCUserDataList {
2525
set { self.users[index] = newValue }
2626
}
2727

28+
public override var debugDescription: String {
29+
var rtn: String = "XCUserDataList["
30+
for (i, user) in self.users.enumerated() {
31+
if i > 0 { rtn += ", " }
32+
rtn += user.debugDescription
33+
}
34+
rtn += "]"
35+
return rtn
36+
}
37+
2838
/// Create a new empty instance of a User Data List
29-
public init() {}
39+
public override init() {
40+
super.init()
41+
}
3042
/// Create a new instance of a User Data List from file
3143
///
3244
/// - Parameters:
@@ -45,6 +57,7 @@ public final class XCUserDataList {
4557
}
4658
}
4759
}
60+
super.init()
4861

4962
}
5063

@@ -112,15 +125,3 @@ extension XCUserDataList: Sequence {
112125
return self.users.makeIterator()
113126
}
114127
}
115-
116-
extension XCUserDataList: CustomDebugStringConvertible {
117-
public var debugDescription: String {
118-
var rtn: String = "XCUserDataList["
119-
for (i, user) in self.users.enumerated() {
120-
if i > 0 { rtn += ", " }
121-
rtn += user.debugDescription
122-
}
123-
rtn += "]"
124-
return rtn
125-
}
126-
}

Sources/XcodeProj/XCWorkspace/objects/XCWorkspace.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010

11-
public final class XCWorkspace {
11+
public final class XCWorkspace: NSObject {
1212

1313
/// Shared Data folder name
1414
internal static let SHARED_DATA_FOLDER_NAME: String = "xcshareddata"
@@ -39,6 +39,7 @@ public final class XCWorkspace {
3939
self.sharedData = try XCSharedData(fromURL: url.appendingDirComponent(XCWorkspace.SHARED_DATA_FOLDER_NAME), usingFSProvider: provider)
4040
self.userdataList = try XCUserDataList(fromURL: url.appendingDirComponent(XCWorkspace.USER_DATA_LIST_FOLDER_NAME),
4141
usingFSProvider: provider)
42+
super.init()
4243
}
4344

4445
/// Get all save actions that are needed

Sources/XcodeProj/XCWorkspace/objects/xcdebugger/XCDebugger.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import RawRepresentableHelpers
1010

1111

1212
/// The debugging package where debugging data is stored
13-
public class XCDebugger {
13+
public class XCDebugger: NSObject {
1414

1515
/// the debugging package folder name
1616
public static let DEBUGGER_FOLDER_NAME: String = "xcdebugger"
@@ -21,8 +21,9 @@ import RawRepresentableHelpers
2121
let breakpoints: Breakpoints
2222

2323
/// Create a new debugging package
24-
public init() {
24+
public override init() {
2525
self.breakpoints = Breakpoints()
26+
super.init()
2627
}
2728

2829
/// Load a debugging package from the given path
@@ -34,6 +35,7 @@ import RawRepresentableHelpers
3435

3536
self.breakpoints = try Breakpoints(fromURL: url.appendingFileComponent(XCDebugger.BreakpointsFileName),
3637
usingFSProvider: provider)
38+
super.init()
3739

3840
}
3941

Sources/XcodeProj/XCWorkspace/objects/xcdebugger/XCDebuggerBreakpoints.swift

+9-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
extension XCDebugger {
1616

1717
/// The collection of breakpoints for the project for the given user
18-
public class Breakpoints {
18+
public class Breakpoints: NSObject {
1919

2020
public enum Error: Swift.Error {
2121
case schemeDocumentMissingRootNode
@@ -26,7 +26,7 @@ extension XCDebugger {
2626
}
2727

2828
/// An action to perform on a breakpoint
29-
public class BreakpointAction {
29+
public class BreakpointAction: NSObject {
3030

3131
/// The breakpoint action type
3232
///
@@ -107,6 +107,7 @@ extension XCDebugger {
107107
/// - Parameter actionType: The action type of this acion
108108
public init(actionType: ActionType) {
109109
self.actionType = actionType
110+
super.init()
110111
}
111112

112113
/// Decode the breakpoint action from the given xml element
@@ -117,6 +118,7 @@ extension XCDebugger {
117118
throw Error.attributeNotFound(attribute: "ActionExtensionID", path: element.xPath)
118119
}
119120
self.actionType = ActionType(rawValue: atNode.stringValue!)
121+
super.init()
120122
}
121123

122124
/// Encodes the given action into an XMLElement
@@ -391,7 +393,7 @@ extension XCDebugger {
391393
}
392394

393395
/// A project breakpoint
394-
public class Breakpoint {
396+
public class Breakpoint: NSObject {
395397
/// The type of breakpoint
396398
///
397399
/// - fileBreakPoint: A file breakpoint
@@ -441,6 +443,7 @@ extension XCDebugger {
441443
public let breakpointType: BreakpointType
442444
public init(breakpointType: BreakpointType) {
443445
self.breakpointType = breakpointType
446+
super.init()
444447
}
445448

446449
/// Decode the breakpoint from the given xml element
@@ -451,6 +454,7 @@ extension XCDebugger {
451454
throw Error.attributeNotFound(attribute: "BreakpointExtensionID", path: element.xPath)
452455
}
453456
self.breakpointType = BreakpointType(rawValue: atNode.stringValue!)
457+
super.init()
454458
}
455459

456460
/// Encodes the given breakpoint into an XMLElement
@@ -592,10 +596,11 @@ extension XCDebugger {
592596

593597

594598
/// Create new empty breakpoints list
595-
public init() {
599+
public override init() {
596600
self.type = 1
597601
self.version = 2.0
598602
self.breakpoints = []
603+
super.init()
599604
}
600605

601606
/// Create new breakpoints list from the xml data

0 commit comments

Comments
 (0)