Xcode plist 文件 - 注释消失,文件重新格式化

发布于 2024-10-06 01:04:35 字数 256 浏览 1 评论 0原文

我刚刚注意到,如果你的 Xcode 项目中有一个 .plist 文件(它是 Info.plist 文件还是其他文件并不重要 - 在我的例子中它是其他 .plist 文件)并且你将该文件编辑为源代码文件(右键单击文件打开方式 -> 源代码文件),然后切换回 XML 属性列表(右键单击文件打开方式 -> XML 属性列表),进行一些更改并保存,然后当您再次将其作为源代码打开时,所有格式和注释都会被删除。

有谁知道如何处理这种行为?我是否必须始终将文件作为源代码进行编辑?

I have just noticed, that if you have an .plist file in your Xcode project (it does not matter whether it is the Info.plist file or other - in my case it was other .plist file) and you edit the file as a source code file (right-click on file Open As->Source Code File) and then you switch back to XML property List (right-click on file Open As->XML Property List), make some changes and save, then all your formatting and comments are dropped when you open it again as a source code.

Does anyone know how to deal with such behaviour? Do I have to stick editing the file as source code ALWAYS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

别在捏我脸啦 2024-10-13 01:04:35

Xcode 似乎认为 标签损坏了数据。在 Xcode 中查看 plist 时,它还会删除 XML 样式的
似乎字符串条目例如

<key>Comment</key>
<string>My comment</string> 

是可靠地保留注释的唯一方法。

Xcode seems to believe that the <comment> tag corrupts the data. It will also strip out XML-style <!-- comments --> when viewing the plist in Xcode.
It seems that a string entry, e.g.

<key>Comment</key>
<string>My comment</string> 

is the only way to reliably persist the comments.

就是爱搞怪 2024-10-13 01:04:35

有趣的是,即使使用外部属性列表编辑器,所有 XML 注释也会消失,完全可重现。似乎您必须始终将其作为源文件打开才能保留您的评论。

或者,您可以将您的评论放在标签中:

<comment>my comments</comment>

我刚刚尝试在 Eclipse XML 编辑器中编辑我的 test.plist。在那里我可以做任何我想做的事。如果您希望保留注释,也许您应该使用不同的 XML 编辑器。

Interesting thing, fully reproducible even with external property list editor all XML comments disappear. Seems like you have to always open it as source file to keep your comments.

Alternatively you may put your comments within tags:

<comment>my comments</comment>

I just tried out to edit my test.plist in the Eclipse XML editor. There I can do whatever I want. Maybe you should use a different XML editor, if you want your comments preserved.

┊风居住的梦幻卍 2024-10-13 01:04:35

我还观察到,如果将 CDATA 放置在 PList 文件中的 String 元素内,XCode 将自动剥离所有实体的 CData 和 XML 编码。

I have also observed that if you place CDATA within String elements in a PList file, XCode will automatically strip the CData and XML encode all entities.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文