Localizable.strings - The data couldn’t be read because it isn’t in the correct format
Solution 1
It seems like SVN is having some issue with this file. As it consider it to be a binary file. It is inserting a lot of non printable characters between each characters. I still couldn't find a proper solution. Just changing the Localizable.string files from production PC for avoiding any issue with it.
Update: Updating the SVN client (smartSVN) to the latest version solved the issue. It seems one of my colleague was using a older version. When he commited the change to localizable file it caused the error.
Solution 2
- Use plutil from the Terminal:
you have to run it for each version of the localizable file. E.g
cd
into your project rootcd eb.lproj
- you can replace this with any localisation you are working with.plutil -lint Localizable.strings
When you run step 3, you will either be shown an error, telling you what is wrong with your file. Or you will be told the file is OK
Note that plutil output is bad, it seems it always says "Unexpected character at line 1" but above that output, it prints other stuff like missing semicolon on line 121, and that is the real error
Solution 3
For me, it was missing semi-colons. If you use a tool to generate .strings
file, make sure there are no un-escaped quotes that may 'eat' the delimiting semi-colons.
Solution 4
pl < Localizable.strings is better than plutil -lint Localizable.strings
Log will show something like this
2019-08-14 16:39:34.066 pl[21007:428513] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 427. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug. 2019-08-14 16:39:34.068 pl[21007:428513] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 427. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug. 2019-08-14 16:39:34.071 pl[21007:428513] *** Exception parsing ASCII property list: NSParseErrorException Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character / at line 1" UserInfo={NSDebugDescription=Unexpected character / at line 1, kCFPropertyListOldStyleParsingError=Error Domain=NSCocoaErrorDomain Code=3840 "Missing ';' on line 427" UserInfo={NSDebugDescription=Missing ';' on line 427}}
Solution 5
Fastest way to detect the line with the issued string is to :
- right click the strings file and
- then Open as/ASCII property list.
Xcode will immediately tell you in what line there's an error.
Related videos on Youtube
![Rashad](https://i.stack.imgur.com/CvmkW.jpg?s=256&g=1)
Rashad
Always wanted to learn new things and be updated with current situations. StackOverflow showed me you don't only learn from answers, questions are the best way of learning. I got a lot of help from StackOverflow. Just trying to payback.. :) #SOreadytohelp
Updated on October 22, 2021Comments
-
Rashad over 2 years
If I copy something from textedit or web and paste it to localizable file it shows this compilation error. If I type those in localizable file it does not show any error. I am assuring you that I using the correct format and ';' in the file.
"New" = "New"; "In Progress" = "In Progress"; "Waiting" = "Waiting"; "Closed" = "Closed";
-
Rashad over 6 yearsNo it's not the case. There are some non printable character in the strings! May be its related to xocde update or something!
-
Rashwan L over 6 yearsYou can post it in your answer and we can analyze it. Hard to say what’s not working with the little info you’ve provided so far.
-
Rashad over 6 yearsMy SVN is considering the .string file as binary file. Are you sure you ran into something like this?
-
Alexander Tumanin about 6 yearsIt shows me
Unexpected character " at line 1
, and it is the first string like"app_name"="Any Name"
-
Mecki about 5 yearsWhy? String files are allowed to be UTF-8 as well. All my string files are always UTF-8 and that has never been a problem. Actually there is an Xcode setting that allows you to choose which files Xcode shall write on output when copying string files and even that setting allows you to choose UTF-8, UTF-16 or binary.
-
Alexandre G about 5 yearsHey yeah, I've realized later what you are describing. I think the error is due to Xcode thinking the file is in one encoding, while factually it's in another.
-
Mecki about 5 yearsUTF-16 files require a BOM. If there is no BOM, macOS usually assumes UTF-8. But if you want to use UTF-8 in a place where UTF-16 is expected, this often works as well if you place an UTF-8 BOM (BOMs are optional for UTF-8 but macOS usually recognizes them). de.wikipedia.org/wiki/Byte_Order_Mark
-
Omar N Shamali about 5 yearsthe semicolon thing is my problem since i switched to swift
-
BjornW about 5 yearsNote that plutil output is bad, it seems it always says "Unexpected character at line 1" but above that output, it prints other stuff like missing semicolon on line 121, and that is the real error...
-
Oleh Veheria over 4 yearsThis is the best solution and it resolved my problem. "plutil" shows an error on the 1st symbol, but "pl < Localizable.strings" is really better and it show the proper number of line where you have a problem with *.plist
-
BB193DEV over 4 yearsDefinitely the better solution. It gives you more information and the line number for the issue, rather than a generic output.
-
KZoNE over 3 yearsGreat, Thanks bro, Saved my day (Y)
-
DiscDev over 3 yearsSame problem here. Thank you!
-
Chanchal Raj over 3 yearsFor me plutil was showing the same error at line 1, although there wasn't any. But
pl < Localizable.strings
worked for me. -
Sergio about 3 yearsWhere can we read the docs for this pl command? Can't find the < anywhere; anyway this should be part of Xcode and tell us where exactly is the problem instead of telling us to go find a wrong char in a file with hundreds of thousands of chars! stupid... open as ASCII Property List is not working here.
-
Shawn Frank almost 3 yearsthis answer is the real GOAT, would never have figured this out as XCode gives a very unhelpful error ...
-
Eyzuky almost 3 yearsthis helped me easily find the root cause
-
Adnan almost 3 yearsthis is the second time I have this problem because of missing Semi-colon. I had a very long error log but they could not bother to mention a missing Semi-colon
-
Abdou Sarr over 2 yearsthis answer was a lifesaver. thank you :)
-
RyanG over 2 years@ChanchalRaj you just saved me sooooo much time ty! That commend worked
-
RyanG over 2 yearsThis is the best solution!
-
iOS Lifee about 2 yearsSuperb solution
-
xgqfrms about 2 yearsIt's a very clear and simple solution, thanks a lot!