Swift String Catalog Localisable

I have been desperately trying to fill the string catalogue with values in a Swift project (storyboard interface) for days. If I have implemented the instructions on the internet correctly, it is only required:

  1. add a string catalogue file
  2. set the entry "Localization Prefers String Catalogs" to YES in the Build options.
  3. add a second language in the string catalogue file.
  4. Build the project

Contrary to expectations, there are no entries in the catalogue that could be translated, it simply remains empty. What am I doing wrong? Is the string catalogue only available for SwiftUI Interface?

Thanks in advance.

Stephan

How do you call localized strings from your code? Using NSLocalizedString or String(localized:)?

I just did what I described above. No separate call, only build the project but no entries are created.

OK, maybe the answer was too simple, nobody expected me to look for this solution:

Xcode can of course only recognise the strings if they were previously marked with String(localized: "Your text").

So far I have understood it now. However, I have not yet managed to find out how Xcode recognises texts that have been defined in the storyboard, i.e. on the user interface builder, in various elements such as buttons, labels etc. outside the code. Such texts do not appear in my file localizable.xcstrings (string catalogue) yet. How can I persuade Xcode to include such texts in the string catalogue?

Stephan

In the same place you set Localization Prefers String Catalogs. Have you enabled Use Compiler to Extract Swift Strings?

And you need to build your project in order for the text to be displayed in the catalog.

Swift String Catalog Localisable
 
 
Q