Xcode 11/iOS 13 Localization issue

Xcode 11 is now officially released, but the things seem not to have been changed. I have also a table with static cells, the cells' titles are correctly localized using objectIds, and this approach also used to work fine for years. But since iOS 13 I must create IBOutlets and localize the static cells in viewDidLoad. If somebody has a better idea, welcome!


I faced the same issue with Xcode 11 GM. In my case, localization strings for title UILabel in static UITableViewCell are not applied.

Here is my workaround;

  1. Copy the labels' Object ID into Accessibility Identifier with the storyboard manually.
  2. Implement the following codes in the UITableViewDataSource class.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = super.tableView(tableView, cellForRowAt: indexPath)
    if let label = cell.textLabel, let id = label.accessibilityIdentifier, id.count > 0 {
        let key = id + ".text"
        let localizedString = NSLocalizedString(key, tableName: "Main", comment: "")
        if key != localizedString {
            label.text = localizedString
        }
    }
    return cell
}

Update: The issue seems to be fixed in Xcode 11.2

--

This is now acknowledged as an issue in the release notes for Xcode 11.1 GM.

UITableViewCell labels in storyboards and XIB files do not use localized string values from the strings file at runtime. (52839404)

https://developer.apple.com/documentation/xcode_release_notes/xcode_11_1_release_notes/


The workaround provided by lavox also worked for me. In my app I'm using objective-c. This is the counterpart:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
    if(cell != Nil) {
        UILabel *label = cell.textLabel;
        NSString *labelId = label.accessibilityIdentifier;

        if (labelId.length > 0) {
            NSString *key = [labelId stringByAppendingString:@".text"];
            NSString *localizedString = NSLocalizedStringFromTable(key, @"Main", @"");
            if (key != localizedString) {
                label.text = localizedString;
            }
        }
    }
    return cell;
}