How can I check if there are any errors in the file and where I am getting these errors? In the other words, How can I debug Localizable.strings file in Xcode ?
Unfortunately, Xcode dosesn't show line with error. If you or another developer was changing Localisable.strings recently, probably one of added / changed lines is missing semicolon at end (see answer under this question: Localizable.strings corrupted? ). If file is big and / or error is not easy to see probably lucianoenrico answer will be helpful. I will quote it now:
To get more detailed informations you can use the Property List utility from the command line:
plutil -lint <your_strings_file>.strings
the
-lint
switch is for checking the syntax. If you have an error you'll get line number and more informations, and in general better directions on how to fix the issue.
If it is a semicolon issue you can also open corrupted file, search for ";" and look for line without highlighted ";" at end. Also look for block comments without closing "*/" and unescaped or incorrect quotation marks (need \"). This last issue is visible because part of string changes color.
I recently released an open source tool, Locheck, that does exactly what you're asking for. It validates your .strings and .stringsdict files (and Android strings.xml files as well) for common errors.
I'd suggest using a tool like https://github.com/SwiftGen/SwiftGen, which will fail to compile if a file contains an error. You then get compile time errors if the file is invalid as well as if you accidentally remove a key that you are using in your app.
© 2022 - 2024 — McMap. All rights reserved.