Ibtool creates a .strings file that is unreadable in xcode

I use ibtool to localize my feathers. I run the following command:

ibtool --generate-strings-file MainMenu.strings en.lproj/MainMenu.nib 

Then I add the generated .strings file to the xcode project so that I can later reference and edit it.

When I do this, if I select the .strings file in xcode, it will display a bunch of question marks and garbage. However, if I do not want to add the file and manually open it with xcode, it reads the file perfectly.

I can only guess that ibtool encodes the file in an unreadable xcode format.

If I open the .strings file in xcode, copy the contents to the clipboard, close the file, add the .strings file to xcode, replace its garbage contents with the contents in the clipboard, and then save the file, everything is fine. I also notice that this will reduce the size of the .strings file by half.

Any guidance would be appreciated.

Thanks!

+4
source share
1 answer

Yes, somehow Xcode cannot automatically determine the encoding of the generated file, which is UTF-16, as required by the specification. But when you add the generated file to Xcode, you can choose the character encoding (by default it corresponds to UTF-8). For this right, there should be a drop-down list below "Copy items to target groups folder." Just select UTF-16 and everything will be fine. You can also choose the encoding in which Xcode opens the file at any other time. To do this, simply right-click the string file, select "get information", and you should get a drop-down list of encodings.

+6
source

All Articles