XCode报告本地化的plist已损坏 [英] XCode reports localized plist is corrupt

查看:724
本文介绍了XCode报告本地化的plist已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个plist文件,我在我的应用程序中使用,我可以本地化,所以我在我的项目中得到两个条目,一个用于英语,一个用于西班牙语,当我编译运行应用程序时它可以工作但当然在这个阶段内容是相同的。

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.

然后在Finder中将西班牙plist替换为已翻译成西班牙语的plist,我可以在XCode编辑器中查看内容没有问题。

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:错误:读取plist:数据无法读取,因为它已被破坏。

.../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?

推荐答案

可能发生的一件事是有人弄乱了你的一个标签。

One thing that can happen is someone messed up one of your tags.

在Xcode中右击你的西班牙语plist,选择 Open AS 然后源代码

In Xcode right click on your Spanish plist, select Open AS then Source Code

然后检查你的plist以确保你的所有开始和结束标签仍然存在,没有拼写错误,那里是否有任何垃圾字符,那你不是试图在整数等中使用字符串:

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:

示例:

<?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>

我曾经遇到过一些问题,当某些东西被复制并从PDF中粘贴到Xcode中时(某种不正确的)符号可能?)当我重新进入它时,它工作正常。此外,通常很难从文字处理器生成有效的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.

这篇关于XCode报告本地化的plist已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆