Xcode“无法解析Info.plist的内容”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19642102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode "Cannot parse contents of Info.plist"
提问by jhilgert00
I just hit a brick wall with xCode not wanting to parse my Info.plist file. I've replaced the file several times with older (identical) versions of the file that I had previously backed up, and I'm still getting the same error.
我只是碰到了 xCode 不想解析我的 Info.plist 文件的砖墙。我已经多次用我之前备份的文件的旧(相同)版本替换了该文件,但我仍然遇到相同的错误。
Here is the complete error message:
这是完整的错误消息:
couldn't parse contents of '/Users/...Info.plist': The data couldn't be read because it isn't in the correct format.
I'm clueless on this one. I'm using xCode 5.0.1, Mavericks
我对这个一窍不通。我正在使用 xCode 5.0.1,小牛队
采纳答案by jhilgert00
Looks like replacing the file with a backup, then deleting the derived data for the project in Organizer was the cure. Hope this helps someone else later on.
看起来像用备份替换文件,然后在管理器中删除项目的派生数据是治疗方法。希望这可以帮助其他人以后。
回答by Vizllx
This is one of the best way to detect on which line the error is occurring.
这是检测错误发生在哪条线上的最佳方法之一。
Just go the directory where the plist file is present then write this command on terminal->
只需转到存在 plist 文件的目录,然后在终端上写入此命令->
plutil filename.plist
回答by capikaw
Another cause of this issue can be from attempting to put URLs (really just slashes etc.) in your app-Info.plist.
此问题的另一个原因可能是尝试将 URL(实际上只是斜杠等)放入您的 app-Info.plist。
Get around it by simply raising the -traditional
flag inside of the Info.plist Other Preprocessor Flags
option in your project build settings.
通过简单地在项目构建设置-traditional
中的Info.plist Other Preprocessor Flags
选项内提高标志来解决它。
回答by Immanito
I think you have used source-control tools, you can use basic text-edit tool without Xcode to open this plist, command + F to find "<<<<<" or ">>>>>", then you will probably find error string such as:
我想你已经使用过源代码控制工具,你可以使用没有Xcode的基本文本编辑工具打开这个plist,command + F找到“<<<<<”或“>>>>>>”,那么你可能会查找错误字符串,例如:
<<<<<<< .mine
>>>>>>> .r605
select the correct string, and delete the other one, error is resolve!
选择正确的字符串,删除另一个,错误解决!
回答by Surpher
I personally ruined the file when git merge raised conflicts. .plist is an XML file and git conflict added <<<< and >>>> in there to tag the differences.
当 git merge 引发冲突时,我个人破坏了文件。.plist 是一个 XML 文件,并且在其中添加了 git 冲突 <<<< 和 >>>> 以标记差异。
Find the .plist file in Finder (in one of your project's folders). Open it in a text editor, find the lines that don't look like proper XML, remove them and be sure to remove the duplicate XML line/node (due to pre and post git recorded changes).
在 Finder 中找到 .plist 文件(在您的项目文件夹之一中)。在文本编辑器中打开它,找到看起来不像正确 XML 的行,删除它们并确保删除重复的 XML 行/节点(由于 git 记录的前后更改)。
回答by Jason King
When building for iOS, the Info.plist may be corrupted whenever Default Orientation is set to Auto Rotation. The Info.plist file is created properly on the first build, but subsequent builds results in...
在为 iOS 构建时,只要默认方向设置为自动旋转,Info.plist 可能会损坏。Info.plist 文件是在第一次构建时正确创建的,但后续构建会导致...
<key>UIInterfaceOrientation</key>
<string></string>
</string>
... at this point Xcode fails to build the project.
...此时 Xcode 无法构建项目。
回答by Kelan
I was having the same error, and realized the issue was that I had a URL (e.g. http://example.com/something
) as a value in my Info.plist, and I just switched on pre-processing for it (without the -traditional
flag). Apparently Xcode will treat the //
as a comment marker, and omit the rest of the line.
我遇到了同样的错误,并意识到问题是http://example.com/something
我的 Info.plist 中有一个 URL(例如)作为值,我只是打开了它的预处理(没有-traditional
标志)。显然 Xcode 会将 视为//
注释标记,并省略该行的其余部分。
A work-around I found is to embrace the pre-processor, like so:
http:/${}/example.com/something
, which breaks up the //
by putting an empty string substation in the middle so it doesn't look like a comment to Xcode, but after pre-processing it's back to a normal URL.
我发现的一种解决方法是采用预处理器,如下所示:
http:/${}/example.com/something
,它//
通过在中间放置一个空字符串变电站来分解它,因此它看起来不像对 Xcode 的注释,但在预处理后它又回来了到一个普通的网址。