Skip to content

Commit 67d78d2

Browse files
mokagioclaude
andcommitted
Teach the lint script about DERIVED_FILE_DIR
A `sourceTree` the script does not know makes the whole project file undecodable, failing the `[Lint] Check AppLocalizedString usage` phase after the Swift compile has already succeeded. Failing there is right — an unresolvable reference means a file silently goes unlinted — but the report was `The data couldn't be read because it isn't in the correct format`, naming neither the setting nor the value. `localizedDescription` was throwing that detail away. Interpolating the error itself yields `Cannot initialize SourceTree from invalid String value SOME_FUTURE_DIR`, with the offending object's UUID and key path. --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 85f7309 commit 67d78d2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Scripts/BuildPhases/LintAppLocalizedStringsUsage.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extension Xcodeproj {
7878
return object.path.map { groupURL.appendingPathComponent($0) } ?? groupURL
7979
case .projectRoot:
8080
return object.path.map { URL(fileURLWithPath: $0, relativeTo: projectDirectory) } ?? projectDirectory
81-
case .buildProductsDir, .devDir, .sdkDir:
81+
case .buildProductsDir, .derivedFileDir, .devDir, .sdkDir:
8282
print("\(self.projectURL.path): warning: Reference \(objectUUID) is relative to \(object.sourceTree.rawValue), which is not supported by the linter")
8383
return nil
8484
}
@@ -206,6 +206,7 @@ extension Xcodeproj {
206206
case group = "<group>"
207207
case projectRoot = "SOURCE_ROOT"
208208
case buildProductsDir = "BUILT_PRODUCTS_DIR"
209+
case derivedFileDir = "DERIVED_FILE_DIR"
209210
case devDir = "DEVELOPER_DIR"
210211
case sdkDir = "SDKROOT"
211212
var description: String { rawValue }
@@ -321,7 +322,7 @@ do {
321322
print("Done! \(violationsFound) violation(s) found.")
322323
exit(violationsFound > 0 ? 1 : 0)
323324
} catch let error {
324-
print("\(projectPath): error: Error while parsing the project file \(projectPath): \(error.localizedDescription)")
325+
print("\(projectPath): error: Error while parsing the project file \(projectPath): \(error)")
325326
exit(2)
326327
}
327328

0 commit comments

Comments
 (0)