How do I comment lines in .plist file?
Asked Answered
Y

2

87

How do I comment out lines in my .plist file in my iOS/Mac projects?

I want to comment out the settings that I don't want to expose for this version of the project, but I may want to expose it later.

Yanez answered 2/12, 2013 at 4:37 Comment(0)
Y
154

Syntax of plist is pretty much like XML, so you can use XML style comments.

<!--
<dict>
    <key>Hello</key>
    <string>World</string>
</dict> 
-->
Yanez answered 2/12, 2013 at 4:37 Comment(2)
By the way, you can select a portion of plist text and press cmd-/ (like you do for making a single-line comment in regular .m, .h files) and XCode will comment selected block for you automatically.Diamond
Unfortunately cmd-/ no longer works in Xcode Version 11.0 (11A420a)Archipenko
A
19

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.

Asturias answered 2/12, 2013 at 4:55 Comment(2)
This way of adding a key/string pair still works, xcode9. It conforms to the DTD, apple.com/DTDs/PropertyList-1.0.dtdEvanne
Mind you, Xcode removes any comments from plist files once they are opened in xcodeUnclog

© 2022 - 2024 — McMap. All rights reserved.