xcode Info.plist 格式不正确

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30814623/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:17:12  来源:igfitidea点击:

Info.plist not in correct format

iosobjective-cxcodexcode6info-plist

提问by pwoerfulafhjksdh

I was working through my iOS Xcode project just fine, and then all of a sudden when I tried to run it, I started getting the error below:

我在我的 iOS Xcode 项目中工作得很好,然后突然当我尝试运行它时,我开始收到以下错误:

error: couldn't parse contents of '/Users/pavitarsidhu/Desktop/AmigoDash/SidebarDemo/AmigoDash-Info.plist': The data couldn't be read because it isn't in the correct format.

I'm really confused. I've looked at the past StackOverflow questions and still have not been able to fix this. Is there anyway to just generate a new infoplist? What do you guys think?

我真的很困惑。我已经查看了过去的 StackOverflow 问题,但仍然无法解决这个问题。无论如何只生成一个新的infoplist?你们有什么感想?

采纳答案by matt

A plist file is an XML document in a tightly specified format; both XML and the Property List structure have very strict rules. You can easily mess things up by accident if you attempt to edit the info.plist manually (i.e., as text) by saying Open As > Source Code:

plist 文件是严格指定格式的 XML 文档;XML 和属性列表结构都有非常严格的规则。如果您尝试通过说 Open As > Source Code 手动编辑 info.plist(即,作为文本),您很容易意外地将事情搞砸:

enter image description here

在此处输入图片说明

You are unlikely to get this format right. Thus, you should always edit the info.plist with Open As > Property List:

您不太可能正确使用此格式。因此,您应该始终使用 Open As > Property List 编辑 info.plist:

enter image description here

在此处输入图片说明

This allows the property list editor to generate the XML for you, and it is unlikely to make a mistake in the resulting XML structure. Of course I suppose you couldstill mess up the value of something...

这允许属性列表编辑器为您生成 XML,并且在生成的 XML 结构中不太可能出错。当然,我想你仍然可以混淆某些东西的价值......

回答by Denn

I encountered the same error. Took quite a while to figure it out. Here's how I did it:

我遇到了同样的错误。花了很长时间才弄明白。这是我如何做到的:

  • Go to your terminal
  • Navigate to the location where the plistfile is located e.g cd /user/desktop/app/Runner/info.plist
  • Then use the plutilcommand like so plutil info.plist
  • 转到您的终端
  • 导航到plist文件所在的位置,例如cd /user/desktop/app/Runner/info.plist
  • 然后plutil像这样使用命令plutil info.plist

This will show you where the error is and you can go about correcting it. I hope that helps.

这将向您显示错误所在,您可以着手纠正它。我希望这有帮助。

回答by Dave Dempsey

I had this same issue and it was because plist files do not like &. You have to use &instead of an ampersand.

我有同样的问题,这是因为 plist 文件不喜欢&. 您必须使用&代替与号。

回答by rharding

I had a merge conflict and didn't realize it so there were git annotations in the file. I couldn't open it as a property list but I opened as source code and fixed the issue that way.

我遇到了合并冲突并且没有意识到,所以文件中有 git 注释。我无法将它作为属性列表打开,但我作为源代码打开并以这种方式解决了问题。