Skip to content

Widen Int and UInt arguments in String(localized:) formatting - #40

Merged
piercifani merged 1 commit into
skiptools:mainfrom
piercifani:fix/localized-int-width
Oct 10, 2026
Merged

piercifani merged 1 commit into
skiptools:mainfrom
piercifani:fix/localized-int-width

Conversation

@piercifani

Copy link
Copy Markdown
Contributor

Problem

String(localized:) keys an interpolated Int as %lld and a UInt as %llu. Both read 64-bit arguments, but the values were passed to String(format:) at their native width. On 32-bit Android ABIs (armeabi-v7a), Int is 32 bits, so every following argument is misaligned:

String(localized: "Game \(game) · \(teamName)")  // keyed "Game %lld · %@"

The %@ then reads garbage and crashes in swift_dynamicCastClass ← _NSFormattingDescription ← String.init. On 64-bit ABIs, Int and Int64 have the same size, so nothing changes there.

Fix

In androidLocalizedString, widen Int to Int64 and UInt to UInt64 before formatting. The stored interpolation values are unchanged, so the SwiftUI Text path, which hands them to Kotlin, is unaffected.

Testing

Cross-compiled with skip android build --arch armv7 and checked that the edited file was rebuilt. Not run on a 32-bit device or emulator. No test added, because a regression would not show on arm64 or x86_64.

🤖 Generated with Claude Code

Interpolated Int and UInt values are keyed as %lld and %llu, which read
64-bit arguments, but were passed to String(format:) at their native width.
On 32-bit Android ABIs (armeabi-v7a) that misaligns every following argument,
and a later %@ reads garbage and crashes. Widen them to Int64/UInt64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed label Oct 9, 2026
@piercifani
piercifani merged commit b03d068 into skiptools:main Oct 10, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants