Skip to content

Commit 70f9630

Browse files
committed
Simpler implementation for unknown productType
1 parent eacf33e commit 70f9630

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

Scripts/BuildPhases/LintAppLocalizedStringsUsage.swift

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -124,34 +124,6 @@ extension Xcodeproj {
124124
}
125125
}
126126
}
127-
128-
@propertyWrapper
129-
enum AllowUnknownRawValue<T: RawRepresentable>: Decodable where T.RawValue == String {
130-
case known(T)
131-
case other(String)
132-
133-
var wrappedValue: T? {
134-
switch self {
135-
case .known(let v): return v
136-
case .other: return nil
137-
}
138-
}
139-
var projectedValue: String {
140-
switch self {
141-
case .known(let v): return v.rawValue
142-
case .other(let s): return s
143-
}
144-
}
145-
init(from decoder: Decoder) throws {
146-
let container = try decoder.singleValueContainer()
147-
let string = try container.decode(String.self)
148-
if let known = T(rawValue: string) {
149-
self = .known(known)
150-
} else {
151-
self = .other(string)
152-
}
153-
}
154-
}
155127

156128
/// Type used to represent and decode the root object of a `.pbxproj` file.
157129
struct PBXProjFile: Decodable {
@@ -203,8 +175,9 @@ extension Xcodeproj {
203175
struct PBXNativeTarget: PBXObject {
204176
let name: String
205177
let buildPhases: [ObjectUUID]
206-
@AllowUnknownRawValue var productType: ProductType?
207-
178+
let productType: String
179+
var knownProductType: ProductType? { ProductType(rawValue: productType) }
180+
208181
enum ProductType: String, Decodable {
209182
case app = "com.apple.product-type.application"
210183
case appExtension = "com.apple.product-type.app-extension"
@@ -329,7 +302,7 @@ do {
329302
targetsToLint = project.nativeTargets.filter { $0.name == targetName }
330303
} else {
331304
print("Linting all app extension targets")
332-
targetsToLint = project.nativeTargets.filter { $0.productType == .appExtension }
305+
targetsToLint = project.nativeTargets.filter { $0.knownProductType == .appExtension }
333306
}
334307

335308
// Lint each requested target

0 commit comments

Comments
 (0)