Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode reports localized plist is corrupt

I have a plist file that I used in my 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?

like image 318
user7865437 Avatar asked Aug 17 '11 17:08

user7865437


4 Answers

  1. open disk utility repair permissions.

  2. 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.

like image 188
Zen Of Kursat Avatar answered Sep 22 '22 20:09

Zen Of Kursat


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.

like image 25
Cephi Avatar answered Sep 21 '22 20:09

Cephi


That can also happen with strings file if you forget the semicolons at the end of the lines. Silly me.

like image 36
pfs Avatar answered Sep 23 '22 20:09

pfs


This can also happen if you have an & within a string.

Replace:

<string>SomeText & SomeMoreText</string>

With:

<string>SomeText &amp; SomeMoreText </string>
like image 44
jt_uk Avatar answered Sep 21 '22 20:09

jt_uk