Xcode plc file - comments disappeared, file reformatted

I just noticed that if you have a .plist file in your Xcode project (it doesn't matter if it is an Info.plist file or another - in my case it was a different .plist file) and you are editing the file as a source code file (right-click the Open As-> Source Code File), and then you return to the XML property list (right-click the Open As-> XML Property List), make some changes and save, then all your formatting and comments deleted when you open it again as source code.

Does anyone know how to deal with this behavior? Should I embed file editing as source code ALWAYS?

+7
iphone xcode plist info.plist
source share
3 answers

An interesting thing, fully reproducible even with the external property list editor, all XML comments disappear. It looks like you should always open it as a source file to leave your comments.

Alternatively, you can put your comments in tags:

<comment>my comments</comment> 

I just tried changing my test.plist in the Eclipse XML editor. There I can do whatever I want. Perhaps you should use a different XML editor if you want your comments to be saved.

+6
source share

Xcode seems to think the <comment> corrupting data. It will also cross out the XML style <!-- comments --> when viewing a plist in Xcode. It seems like writing a string like

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

- This is the only way to reliably save comments.

+8
source share

I also noticed that if you put CDATA inside String elements in a PList file, XCode will automatically split CData and XML into all objects.

+3
source share

All Articles