mercoledì 13 maggio 2015

Find errors in your iOS project .strings files with Plutil

When you have an syntax error in your application's localization file and you try to build your project, Xcode will give you the follow error:

/Users/Emanuele/git/MyTeamManagerIPhone/MyTeamManagerIPhone/fr.lproj/Localizable.strings:0: Read failed: The data couldn’t be read because it isn’t in the correct format.

Often the error is a missed semicolon somewhere in the file but Xcode won't point it out and when the file is big, find the issue manually can be a timing consuming task.

I found on Stackoverflow a very useful response to a similar problem. The solution is using a utility of OS X called plutil, which allow to check the validity of a property file or convert a plist file to another format.

So if your run the command:

plutil -lint <yourpath>/Localizable.string

you can get a clearer message helping you to find immediately where your file has the problem:

2015-05-14 00:08:12.331 plutil[40933:3760056] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 99. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
/Users/Emanuele/git/MyTeamManagerIPhone/MyTeamManagerIPhone/fr.lproj/Localizable.strings: Unexpected character / at line 1

Nessun commento:

Posta un commento