How to know which line of plist file is incorrect
Asked Answered
K

2

58

I generate plist file for my application from file in csv format.

Everything seems to be correct but when I try to build application or open plist file in XCode i Get an error informing that:

mydata.plist:0: error: reading plist: The data couldn’t be read because it has been corrupted.

File contains a lot of data so it might be hard to manually find line which is incorrect.

Is it possible to validate file and get information which line is incorrect?

Kingly answered 18/3, 2013 at 23:28 Comment(5)
What type of plist is it? NextSTEP? XML? Binary? If it's XML you could try running xmllint on it to see if it's a well-formedness error.Polygraph
A plist file is just an XML file. Use any XML validation tool you can find. Even opening the file in Safari or Firefox will probably tell you if the XML is valid. Though it could be valid XML and still be an invalid plist file.Punt
@rmaddy: There are actually 3 valid plist formats, although one of them (NextSTEP) is deprecated.Polygraph
@KevinBallard Yes, but I figured that since he was creating the plist from a CSV file, it is most likely the XML format.Punt
Yes it is the XML format. I tried to open it in Safari and it opens.Kingly
H
160

Try running the following command in Terminal:

plutil <PATH_TO_FILE>

It will tell you what the problem is and give you the line number.

Horick answered 19/3, 2013 at 0:33 Comment(3)
Thanks, it worked very well. It looks like accidentally my script put string inside <real></real>. That was because my script substituted & with &amp; before splitting csv line into columns... Just a side note :) ...Kingly
If you don't want to type <PATH_TO_FILE>, just type plutil in Terminal, then drag the the file from Finder onto the Terminal window.Chemush
Super helpful; acquainted me with plutil (which has a cute entry on its man page re "STANDARDS" -- "The plutil command obeys no one's rules but its own.") and alerted me that my comment was wrongly preceding the main <dict>.Importunacy
G
3

Open plist file in Chrome browser gives the error line number.

Gifted answered 28/6, 2017 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.