-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Describe the bug
We're experiencing a crash on app launch related to localized strings when using a custom localization extractor (LocalLocalizationExtractor) and swizzling NSBundle.localizedString(...). The crash occurs inside NSError.localizedDescription, which seems to trigger localized string resolution, eventually hitting the swizzled method and crashing.
The crash is happening on the main thread and affects production users, though it is not currently reproducible on our development or test environments.
To Reproduce
Unfortunately, the issue cannot be reliably reproduced. It appears to happen during app startup under some user configurations. Our Localization.swift uses method swizzling to intercept NSBundle.localizedString(forKey:value:table:) and route it through our own extractor.
Stack trace excerpt:
Crashed: com.apple.main-thread
0 trainiac-client LocalLocalizationExtractor.localizedString(for:) (LocalLocalizationExtractor.swift:113)
1 trainiac-client NSBundle.swizzled_LocalizedString(forKey:value:table:) (Localization.swift:105)
...
3 Foundation -[NSError(NSErrorPrivate) _cocoaErrorString:fromBundle:tableName:]
...
11 Foundation -[NSError localizedDescription]
Expected behavior
If Crowdin is intercepting or expecting localization behavior differently than standard Apple mechanisms (especially during NSError string formatting), we'd expect that it gracefully fails over or avoids recursive localization calls that can lead to crashes.
Screenshots
N/A — this is a crash on app startup.
Smartphone (please complete the following information):
- Device: Multiple (e.g. iPhone 13, iPhone 14 Pro)
- OS: iOS 17.x (confirmed across several versions)
- App is built with Swift and uses Crowdin integration for localization
Additional context
We suspect that Crowdin’s SDK or integration may be interfering with or amplifying the issue due to the swizzling or localization loading during error string generation. If Crowdin has internal handling of NSBundle.localizedString(...), it may be conflicting with our own swizzled implementation.
Let us know if there’s guidance on compatibility with swizzled localization or how Crowdin recommends integrating custom localization logic safely.