1

I know there are a bunch of questions and answers about this, but I think my situation is different because it deals with localization. Which is probably why I'm pulling my hair out in understanding why I can't get this warning resolved.

I get the "Format is not a string literal" warning on the following code:

[NSString stringWithFormat:[[NSBundle mainBundle] localizedStringForKey:@"TestCompleted2"
value: @"The test on %@ has completed." table: @"Main"], itemName]

Main.strings:

"TestCompleted2" = "The test on %@ has completed.";

I don't understand A) why its throwing this error and B) how I can fix it.

It clearly has the fill data, so that shouldn't be it. I'm assuming its because localizedStringForKey could return a different string with different formatting placeholders, which is why it is throwing the error. Is that correct? And if so, how do I fix it?

apple4ever
  • 41
  • 5
  • Well that's just odd @matt . I just copy and pasted the code I'm using. Maybe I have a build warning enabled somewhere? I can try a new project and see if I get the same experience as you. – apple4ever Mar 13 '17 at 01:14

1 Answers1

1

Finally had a chance to sit down and debug this. It was due to -Wformat=2 in an xcconfig. Its explained here as to what it does.

Thanks all for taking a look at this. Hopefully this answer will help somebody else.

apple4ever
  • 41
  • 5