Support for Xcode String Catalogs#931
Conversation
|
Of course, after creating this PR I noticed that #886 also exists with an implementation of this. 🤦🏼 |
|
Hello @mbernson |
|
There's a big real-world app that I'm working on that uses R.swift and strings files. I'm going to convert it to string catalogs soon (probably next week) and will test it with this version of R.swift. Also one of the unit tests I wrote is failing on the CI, I have to fix that. But other than that it's done :) @tomlokhorst @mac-cain13 Is there anything else I can do to help get this feature across the finish line? It's also fine for me if PR #886 is merged instead of this one. |
This fixes non-determinism in the parser. Also expanded the tests a little bit.
|
When will the release for CocoaPods be out? Version 7.8.0 doesn’t include any changes |
|
This localization workflow with typed localized strings is now supported in Xcode 26! That removes the need for this PR too. It supports multiple parameters and multiple string tables too. You may have to turn on the build setting "Generate String Catalog Symbols”. Watch this WWDC25 talk from about minute 14:00 to learn more about it. |
That's only for SwiftUI, it's still not supported for UIKit projects |
|
@Wuou There is an overload for let label = UILabel()
label.text = String(localized: .helloWorld)See Apple documentation: https://developer.apple.com/documentation/swift/string/init(localized:options:) |
But I tried, and it works in the library I created. But in the main project, when I tried to do what I saw in the video, xcode didn't automatically generate the keys for me, and when I manually added the keys, I couldn't get any code hints. It's weird |
|
@Wuou In your project's Xcode build settings, have you enabled "Generate String Catalog Symbols"? |
Oh, thank you for your help. It's my table name that doesn't match. However, there is a problem, this interface only supports iOS16 and above, we apply minimum support iOS13 It seems that this generation tool is still used in the low version |
This PR adds support for Xcode String Catalogs to R.swift.
The string catalogs are parsed in a similar fashion to Strings files and Strings Dicts. They output the same type, a StringsTable.
What's changed in this PR
StringsTable+Parser.swiftwith support for parsing string catalogs.RswiftParsersTests.StringCatalogAppas an integration test. This is also used in the checks workflow on GitHub Actions.Fixes #840, #861