From 3abd4d0cfd54fe928270dc5f0349cbe4076c6822 Mon Sep 17 00:00:00 2001 From: cdricms <36056008+cdricms@users.noreply.github.com> Date: Fri, 24 Jul 2026 19:42:40 +0200 Subject: [PATCH] build(apple): flag raw string literals in SwiftUI initializers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The typed-resource rules missed a bare string literal passed as the leading arg of a view initializer (e.g. Label("send_stop_sharing", …)), which is an implicit LocalizedStringKey. Add a rule covering Text/Label/Button/Section/Picker/etc. (empty labels allowed). Fixes the two dynamic-content Text sites it surfaced by switching them to Text(verbatim:). --- apple/.swiftlint.yml | 7 +++++++ apple/VniDrop/Features/Send/TransferDetailsView.swift | 2 +- apple/VniDrop/UI/Components/Components.swift | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apple/.swiftlint.yml b/apple/.swiftlint.yml index 1614011..b9a3f8e 100644 --- a/apple/.swiftlint.yml +++ b/apple/.swiftlint.yml @@ -25,3 +25,10 @@ custom_rules: regex: 'system(Name|Image):\s*"' message: "Use SFSafeSymbols: Image(systemSymbol:) or systemSymbol:." severity: warning + raw_swiftui_string_literal: + name: "Raw SwiftUI string" + # A non-empty string literal as the leading arg of a view initializer is an + # implicit LocalizedStringKey. Empty labels (e.g. Picker("", …)) are allowed. + regex: '\b(Text|Label|Button|Toggle|Link|NavigationLink|Section|Picker|Stepper|TextField|SecureField|DisclosureGroup|Menu|GroupBox)\("[^"]' + message: "Pass a typed L10n.* accessor (or Text(verbatim:)), not a raw string literal." + severity: warning diff --git a/apple/VniDrop/Features/Send/TransferDetailsView.swift b/apple/VniDrop/Features/Send/TransferDetailsView.swift index 534133a..b0358fc 100644 --- a/apple/VniDrop/Features/Send/TransferDetailsView.swift +++ b/apple/VniDrop/Features/Send/TransferDetailsView.swift @@ -112,7 +112,7 @@ private struct DetailDestination: View { } Spacer() if count > 0 { - Text("\(count)") + Text(verbatim: "\(count)") .font(.footnote) .foregroundStyle(.secondary) } diff --git a/apple/VniDrop/UI/Components/Components.swift b/apple/VniDrop/UI/Components/Components.swift index eb0dc4e..4fb2c0f 100644 --- a/apple/VniDrop/UI/Components/Components.swift +++ b/apple/VniDrop/UI/Components/Components.swift @@ -42,7 +42,7 @@ struct ProgressRow: View { label.font(.subheadline).lineLimit(1) Spacer() if let progress { - Text("\(Int(progress * 100))%").font(.caption).foregroundStyle(.secondary) + Text(verbatim: "\(Int(progress * 100))%").font(.caption).foregroundStyle(.secondary) } } if let detail {