Xcode plist file - comments vanished, file reformatted
Asked Answered
G

3

7

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?

Grillroom answered 3/12, 2010 at 13:31 Comment(0)
D
6

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.

Disruption answered 3/12, 2010 at 14:16 Comment(0)
L
8

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.

Leopard answered 9/11, 2012 at 23:15 Comment(0)
D
6

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.

Disruption answered 3/12, 2010 at 14:16 Comment(0)
A
3

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.

Aphesis answered 5/8, 2013 at 19:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.