Localized Strings are always in English in UITests (Snapshot)

678 Views Asked by At

I'm pretty new to Fastlane and love the idea of Snapshot, but I got a little problem.
When I'm trying to create a new set of screenshots I'm facing the problem that the UITests don't use the correct localized Strings to fetch the UI elements.

My current state is based on this Stack entries: XCode 7 UITests with localized UI

The localization method:
func localizedString(_ key: String) -> String { let uiTestBundle = Bundle(for: MyUITests.self) return NSLocalizedString(key, bundle: uiTestBundle, comment: "") }
Trying to perform a tap that way:
app.navigationBars[localizedString("key_1")].buttons[localizedString("key_2")].tap()

The error I get is the following: No matches found for "Rolling stone" NavigationBar
Rolling stone is the Base/English Localization of the key, but there should be a German one. So for any reason the UITest always picks the English Localization.

Does anybody have an idea how to troubleshoot this? I checked the SnapshotHelper and it passes a "de-DE" as the language, so that's not the point.
But I just can't find the Bug :(

1

There are 1 best solutions below

1
On

Localization

This link here should be sufficient enough to solve your problem. You simple pick the correct language option during the test tab under edit scheme option.