03 May Is Your Custom Created PLIST Unreadable and in the Incorrect Format?
Recently I’ve been building all sorts of custom scripts; writing the outputs to a PLIST file. Some of the custom scripts are simple with only a line or two of outputs being written, but other PLIST files have been much more complex with hundreds of output lines.
Despite my best efforts in paying attention to all of the small details, such as ensuring I have properly typed in the correct syntax for each key, occasionally I’ll run into an error when I try to open the PLIST file with Xcode.
The Data Couldn’t Be Read Because it isn’t in the Correct Format
I should mention that TextWrangler will open and display the file just fine. So using Xcode is a good way to validate your PLIST file has been properly built.
Luckily, OS X includes a utility, plutil, that will give you the exact line number and hopefully an insightful error code as to what the issue is. To use the utility, all you need to do is follow the 2 steps below.
- Launch Terminal
- Type in plutil /path/to/your/file/filename.plist
I like to just drag my file into the Terminal window and let the path properly populate. It’s up to you, you can drag in your file or you can type it out manually. After so doing, you should receive some information similar to the text below.
Unknown character '/' (0x2f) in <integer> on line 12
Knowing my error was on line 12, using TextWrangler I opened the file to see what I was writing to line 12 in my output file. In this specific example, line 12 shows that I forgot to close out the integer key.
A quick fix to add in the “<” bracket to my script and now my PLIST is fully functioning and when the LANDESK scanner processes it, I can be more confident the attributes will properly insert.