iOS. Apple. Indies. Plus Things.

The Tips Journal Free Preview: plutil

// Written by Jordan Morgan // Sep 27th, 2023 // Read it in about 1 minutes // RE: The Indie Dev Diaries

It’s crazy to even write this, but in about 24 hours (who’s counting, though?) I will have finished my book series. The past two and a half years have been exciting, sometimes long, but absolutely worth it. Today, I’m putting the finishing touches on the bonus journal that comes with the series. I thought I’d share an entry from it to give you a feel of what the journal is like.

Each entry aims to be less than 1,000 words or less. So, you can quickly pick it up, and read something interesting in about five minutes. Some of the entries are about 400 words, some go slightly over 1,000. Here’s one of the shorter ones, covering one my favorite little command line ulities: plutil.

Anyways, without further ado:

Preview begins.

Today, we turn our attention to another useful command line tool, plutil. Like the others we’ve discussed, these are found within Xcode Tools. This little tool helps you manipulate .plist files — one of the most important files in a Xcode project. Using this, we can check whether a .plist file is valid, edit them, convert them back and forth into different formats and more.

There are times when you might want to access .plist files in code, or have them exported or used in a different format. You can easily do that with this tool. Take my book series and the demo project:

$plutil -convert swift info.plist

Here, I’ve noted that I want to convert my app’s info.plist file using Swift into a dictionary. Here’s the result:

A screenshot of plutil converting a dictionary inside Xcode.

I could even do the same thing with Objective-C:

$plutil -convert objc info.plist

Which results in: A screenshot of plutil converting a dictionary inside Xcode.

For Objective-C, we could also generate a header file by appending the -header flag. Beyond Objective-C and Swift, we can also convert .plist files into XML, binary or JSON. This can be nice when using third-party tools which put a user interface over property list files for easier maintenance.

Personally, I find that I like to convert property list files to .json for easier editing:

$plutil -convert json info.plist -r

Then, after my edits are done — I simply put it back to XML:

$plutil -convert xm1 info.plist

Beyond conversions, we can even add or remove keys from property lists:

$plutil -insert/-replace/-remove

Or, perhaps after editing one — we need to ensure it’s still in a valid format:

$plutil -lint info.plist
info.plist OK

There’s not much else to say about plutil — but not to its detriment. It’s an easy-to-understand tool with one, focused job. And these are things that I absolutely adore finding and learning about! The next time you need to get dirty with a property list file, consider the command line and Terminal for the job.

Preview ends.

So that’s pretty much how each of the journal entries are formed. Short, and straight to the point. If that type of thing sounds great to you, go pick up the series today! I promise you’ll get your money’s worth.

Until next time ✌️.


Spot an issue, anything to add?

Reach Out.