others-how to solve Couldn't parse property list because the input data was in an invalid format in iOS app

Problem

When we develop iOS app with localization , sometimes, we got this problem:

/Users/xxx/XcodeProjects/yyy/zh-Hans.lproj/Localizable.strings:1:1: read failed: Couldn't parse property list because the input data was in an invalid format

Environment

  • iOS programming
  • XCode 11.3
  • Swift 5

Debug

You can debug like this:

Open the terminal app in the root directory of your project:

plutil -lint  Localizable.strings

Check the output of the plutil tool, act according to the suggestions.

Possible Reasons

  • Missing Semi-colon characters.
  • Invalid white space in file.
  • Invalid characters in file.
  • Git merge conflict characters in it!

Solution

  • make sure the strings file name is always Localizable.strings

If you still can not find solution, just do as follows:

Remov all unused strings in my Localizable.String file.