Wednesday, March 23, 2011

Objective C/Xcode 4: Encoding Problem with Localizable.strings files

When compiling your Xcode project and your are using Localization in the Form of Localizable.strings and can happen that your get one of the following Build Errors.

Possible Build Errors

Conversion of string failed. The string is empty. Command /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copystrings failed with exit code 1

Localizable.strings:0: error: validation failed: The data couldn’t be read because it has been corrupted.


These kind of errors can happen if you copy and paste content within Xcode or from external files in your localization files. The consequence is that the encoding of the file changes to for example Western (Mac OS Roman). The Localizable.strings file should be in UTF-16 though.


Like in the picture below, navigate in Xcode to the Localizable.strings location and open it so that you can see all the languages you are supporting.

Left-click on the language file the causes the build error.

Make sure your Utilities View is showing in Xcode. Activate on the button at mark 1 in Picture below.

In the Utilities View select the File Inspector. (Small Logo that looks like Page)

Under Text Settings change the encoding to UTF-16(Marked as 2 in the picture above). The Drop-Down might be grayed out but you can click on it anyways. Click on "Convert" on the Popup.

That's it your project should now compile again.


Patrick Chukwura said...

Awesome...this cleared the error right up.

Anonymous said...

OR you might have failed entering a ; at the end of the line...

Post a Comment