I have a Swift Package that has multiple translations in folders inside a "Resources" folder, e.g. "Resources/de.lproj/Localizable.strings" and "Resources/en.lproj/Localizable.strings".
Since I updated to Xcode 12.5, the App implementing this Swift Package does always fallback to English, it only returns Strings localized in English.
My Package.swift
has "de" as default:
defaultLocalization: "de",
Example: Running the app on a device set to German:
print(Locale.preferredLanguages) // ["de"]
print(Bundle.module.localizations) // ["de", "en", "es", "it", "fr"]
print(NSLocalizedString("Yes", tableName: nil, bundle: .module, value: "", comment: "")) // "Yes" (instead of "Ja" from the German file)
Also setting "App Language" in the iOS Simulator does result in the same issue.
The issue was that the host app does not seem to have any localizations, so the Swift Package won't localize either.
There is a thorough explanation on the Swift Forums: https://forums.swift.org/t/swift-package-manager-localization/46685/6
It sounds like the real issue might be you are expecting libraries to use additional localizations beyond those supported by the main application bundle. If so, setting CFBundleAllowMixedLocalizations to YES in the application’s Info.plist is the proper solution.