I have a plist file that I used in my开发者_StackOverflow app that I can localize so I get two entries in my project, one for English and one for Spanish and when I compile an run the app it works but of course at this stage the contents are identical.
I then in Finder replace the Spanish plist with one that has been translated for me into Spanish and I can in the XCode editor view the content without problem.
However when I try to compile I get an error stating:
.../en.lproj/myData.plist:0: error: reading plist: The data couldn’t be read because it has been corrupted.
But the English one has not been touched?
Surely you can copy a localized file into the project in this manner?
open disk utility repair permissions.
open terminal and run this command:
plutil -s /somewhere/yourfile1.plist
It will make you focus with all details of the problem by showing you the exact error and line. So you'll have to go the reported line & fix it by yourself with a text editor.
One thing that can happen is someone messed up one of your tags.
In Xcode right click on your Spanish plist, select Open AS then Source Code
Then check your plist to ensure all of your opening and closing tags are still there, there are no typos, are there any garbage characters in there, and that you are not trying to use a string in an integer etc:
Example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>1</key>
<dict>
<key>a</key>
<string>a1</string>
<key>b</key>
<string>b1</string>
</dict>
<key>2</key>
<dict>
<key>a</key>
<string>a2</string>
<key>b</key>
<string>b2</string>
</dict>
<key>3</key>
<dict>
<key>a</key>
<string>a3</string>
<key>b</key>
<string>b3</string>
</dict>
</dict>
</plist>
I once had some problems when something was copied and pasted into Xcode from a PDF (some kind of incorrect symbol maybe?) and it worked fine when I just re-entered it. Also its often difficult to generate a valid plist from a word processor.
That can also happen with strings file if you forget the semicolons at the end of the lines. Silly me.
This can also happen if you have an & within a string.
Replace:
<string>SomeText & SomeMoreText</string>
With:
<string>SomeText & SomeMoreText </string>
For benefit of anyone who had my exact problem:
I had the corrupt plist problem too.
My plist had been generated by exporting a spreadsheet in OpenOffice to CSV (in UTF-8 format). Then I'd convert the CSV file to a plist using a simple Python script I'd written. I believe my problem was that there were some cell reference errors in the spreadsheet I saved (i.e. the cells said "Err:511"). The existence of errors was causing the UTF-8 export to fail somehow, hence the corrupt plist.
I have not absolutely verified the above was the case, but I'm pretty sure that was the problem: after I fixed the errors in some cells in OpenOffice, my plist works again.
This answer demonstrates the use of the iconv
command to verify a file is correctly encoded -- could be useful in cases like this.
This happened to me because I managed to drop a random quotation mark (") in my plist. Removed it and got it to work.
I opened the file in TextWrangler all used Cmd-F to search for any characters that might be causing the offence.
For me it was a space in the name of localized string:
Instead of this_is_the_string_we_will_translate
I had this_is_the string_we_will_translate
.
Tricky one to spot.
A great place to start debugging plists is to use an XML validator such as: http://www.w3schools.com/xml/xml_validator.asp
This feature is also built into most web development environments.
Happened to me, missed 0: 2012-12-9T06:00:00Z should be 2012-12-09T06:00:00Z
精彩评论