diff --git a/Package.swift b/Package.swift index c6bc9ec..4d360b2 100644 --- a/Package.swift +++ b/Package.swift @@ -13,12 +13,13 @@ let package = Package( targets: ["XcodeProject"]), ], dependencies: [ - .package(url: "https://github.com/g-Off/ObjectCoder.git", .exact("0.1.0")) + .package(url: "https://github.com/g-Off/ObjectCoder.git", .exact("0.1.0")), + .package(url: "https://github.com/mxcl/Version.git", from: "1.0.0") ], targets: [ .target( name: "XcodeProject", - dependencies: ["ObjectCoder"]), + dependencies: ["ObjectCoder", "Version"]), .testTarget( name: "XcodeProjectTests", dependencies: ["XcodeProject"]), diff --git a/Sources/XcodeProject/Objects+Extensions/PBXReference+Extensions.swift b/Sources/XcodeProject/Objects+Extensions/PBXReference+Extensions.swift index 9fb94af..54a99c4 100644 --- a/Sources/XcodeProject/Objects+Extensions/PBXReference+Extensions.swift +++ b/Sources/XcodeProject/Objects+Extensions/PBXReference+Extensions.swift @@ -36,7 +36,11 @@ public extension PBXReference { return nil } - enum SortOption: String { + enum SortOption: String, CustomStringConvertible, CaseIterable { + public var description: String { + return rawValue + } + case name case type diff --git a/Sources/XcodeProject/Objects/Swift Package/XCRemoteSwiftPackageReference.swift b/Sources/XcodeProject/Objects/Swift Package/XCRemoteSwiftPackageReference.swift index 856f12a..16263f0 100644 --- a/Sources/XcodeProject/Objects/Swift Package/XCRemoteSwiftPackageReference.swift +++ b/Sources/XcodeProject/Objects/Swift Package/XCRemoteSwiftPackageReference.swift @@ -6,6 +6,7 @@ // import Foundation +import Version public final class XCRemoteSwiftPackageReference: XCSwiftPackageReference { public enum Requirement: Encodable { @@ -17,33 +18,6 @@ public final class XCRemoteSwiftPackageReference: XCSwiftPackageReference { case branch case revision } - - public struct Version: CustomStringConvertible, Encodable { - let major: Int - let minor: Int - let patch: Int - - public init(major: Int, minor: Int, patch: Int) { - self.major = major - self.minor = minor - self.patch = patch - } - - init?(_ value: String) { - var integerValues = value.components(separatedBy: ".").compactMap { Int($0) } - guard integerValues.count == 3 else { return nil } - self.init(major: integerValues.removeFirst(), minor: integerValues.removeFirst(), patch: integerValues.removeFirst()) - } - - public var description: String { - return "\(major).\(minor).\(patch)" - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(description) - } - } public struct GitHash: Encodable, CustomStringConvertible { private var value: String