genstrings fails for Swift calls to NSLocalizedString with more than a key and a comment
| Originator: | lithium3141 | ||
| Number: | rdar://24770264 | Date Originated: | 22-Feb-2016 09:29 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 7.3 (7D141l) / OS X 10.11.3 (15D21) |
| Classification: | Other Bug | Reproducible: | Always |
Summary: The genstrings utility searches source files for uses of NSLocalizedString(), extracting the key and other information out to a .strings file for localization and internationalization. genstrings can be run on Swift files in addition to Objective-C .h and .m files. However, invocations of NSLocalizedString() in Swift seem to only be supported by genstrings if they provide a key and a comment, but no other arguments. For example, NSLocalizedString() supports a `value:` argument in Swift; if this is given, an invocation of genstrings on that Swift file will fail, producing the error "Argument is not a literal string." Steps to Reproduce: 1. Download the attached Swift file 2. Invoke genstrings on this file Expected Results: genstrings runs without error. A file Localizable.strings is generated with two keys: "foo" and "bar". Actual Results: genstrings runs, but produces an error for the NSLocalizedString() invocation that provides a value. A file Localizable.strings is generated with only the key "foo". Version: Xcode 7.3 (7D141l) / OS X 10.11.3 (15D21) Notes: http://www.openradar.me/22133811 seems to indicate this has been a problem since at least Xcode 7.0. I tested with Xcode 7.2 and 7.3b3; both produced the same error. Configuration: Tested on a mid-2015 MacBook Pro with Retina with a standalone Swift file, but I believe this applies on any project with Swift code, regardless of platform or device.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
genstrings.swift
"The attached Swift file" above has the following contents: