FlineDev/BartyCrouch

Using customFunction with dynamic String variable in Objective-C

podkovyrin opened this issue · 3 comments

In our library, we have to use a custom function which is a macro:

12: #define DSLocalizedString(key, comment) \
13: [[DSEnvironment sharedInstance].resourceBundle localizedStringForKey:(key) value:@"" table:nil]

When we run bartycrouch lint -x from the build script we got the following error:

extractLocStrings: error: bad entry in file /path/to/header/with/definition.h (line = 12): Argument is not a literal string.

Is there a more right way to use a custom function? Thanks!

I have the same error in swift,but it work

bartycrouch script run before compile sources, then the "key" of NSLocalizedString is not string

@podkovyrin Hey, sorry for getting back so late. But I still want to answer your question (also in case someone else comes across this). So the thing is, that BartyCrouch doesn't itself traverse any code or IB files, instead it just reuses a tool that Apple is shipping part of Xcode, namely extractLocStrings (previously genstrings). And that tool does only support String literals, it does not support variables that are of type String. It would also be hard to detect the actual value of a variable just by reading the code. So I fear that what you requested is out of scope of this project.

If you have any idea how we could solve this in an easy way, feel free to ping me though.


This comment was written during my regular Open Source live stream on Twitch. Follow me there to support my work!