From b65bac021f56fc8740fa0ab4f64ba8a5caa42977 Mon Sep 17 00:00:00 2001 From: cdricms <36056008+cdricms@users.noreply.github.com> Date: Fri, 24 Jul 2026 18:32:15 +0200 Subject: [PATCH] build(apple): enforce typed resources with SwiftLint Add a focused .swiftlint.yml (custom rules only, no default style noise) flagging raw String(localized:) / LocalizedStringKey / systemName|systemImage literals, and wire it as a required pre-build phase that fails the build if SwiftLint is missing (brew install swiftlint). The phase prepends the Homebrew bin dirs since Xcode runs scripts with a minimal PATH. Runs clean on the current tree (0 violations). --- apple/.swiftlint.yml | 27 +++++++++++++++++++++++++++ apple/project.yml | 15 +++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 apple/.swiftlint.yml diff --git a/apple/.swiftlint.yml b/apple/.swiftlint.yml new file mode 100644 index 0000000..1614011 --- /dev/null +++ b/apple/.swiftlint.yml @@ -0,0 +1,27 @@ +# Focused lint for the native app: enforce the typed-resources convention only +# (no default style rules, so this stays signal, not noise). +only_rules: + - custom_rules + +included: + - VniDrop + +excluded: + - VniDrop/Generated + +custom_rules: + raw_localized_string: + name: "Raw localized key" + regex: 'String\(localized:\s*"' + message: "Use a typed L10n.* accessor, not a raw key string." + severity: warning + raw_localized_string_key: + name: "Raw LocalizedStringKey" + regex: 'LocalizedStringKey\("' + message: "Use a typed L10n.* accessor instead of a raw key." + severity: warning + raw_sf_symbol: + name: "Raw SF Symbol" + regex: 'system(Name|Image):\s*"' + message: "Use SFSafeSymbols: Image(systemSymbol:) or systemSymbol:." + severity: warning diff --git a/apple/project.yml b/apple/project.yml index 843a363..806fc85 100644 --- a/apple/project.yml +++ b/apple/project.yml @@ -69,6 +69,21 @@ targets: - sdk: SystemConfiguration.framework - sdk: Security.framework - sdk: libresolv.tbd + preBuildScripts: + # Enforce the typed-resources convention (see .swiftlint.yml). Required: fails + # the build if SwiftLint is missing so the rules can't be silently bypassed. + - name: SwiftLint (typed resources) + basedOnDependencyAnalysis: false + script: | + # Xcode runs build phases with a minimal PATH that omits Homebrew, so add + # the common Homebrew bin dirs (Apple Silicon + Intel) before resolving it. + export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" + if which swiftlint >/dev/null; then + swiftlint lint --config "${SRCROOT}/.swiftlint.yml" + else + echo "error: SwiftLint not installed — run 'brew install swiftlint'" + exit 1 + fi VniDropTests: type: bundle.unit-test