82

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.

0

2 Answers 2

149
+50

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

<!--
<dict>
    <key>Hello</key>
    <string>World</string>
</dict> 
-->
2
  • 4
    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.
    – heximal
    Apr 29, 2015 at 11:32
  • Unfortunately cmd-/ no longer works in Xcode Version 11.0 (11A420a) Oct 4, 2019 at 14:10
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.

2
  • This way of adding a key/string pair still works, xcode9. It conforms to the DTD, apple.com/DTDs/PropertyList-1.0.dtd Oct 10, 2017 at 2:11
  • Mind you, Xcode removes any comments from plist files once they are opened in xcode
    – philk
    May 16, 2022 at 22:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.