objClean is a third-party tool that integrates with your iOS and Mac App Xcode projects to help enforce a standard code style. Many IDEs have this feature builtin, but unfortunately, Xcode 5 isn’t one of them - perhaps the upcoming update in June will rectify this?

The Survey

To get started with objClean, you’ll need create a configuration file by completing the objClean survey. The survey is only 40 multiple choice questions, but if you’re in a bind you can download the StackOverflow version, or the version that is the total average of everybody who has taken the survey. This alone is a great resource to inform you of what the current community standards currently are.

Take a look at the survey before continuing; and then I’ll explain how I proceeded.

I decided to make a custom configuration and compare my results to StackOverflow. I differed to them in the following 3 questions:

Q5. Should the open brace be on the same line as the method signature? (they said yes, I said no).

Q20. Which image best portrays the correct syntax for an else statement? (they said A, I said D).

Q21. Which image best portrays the correct syntax for an else-if statement? (they said A, I said D again).

Also, the website remembers you, so you can modify your configuration file by returning to the survey page at any time.

Now you just need to download your config file and place it in the root directory of your project, and get then App.

The App

You’ll need to spend £6.99 / $12.99 AUD / $9.99 USD to purchase the App from the Mac App Store.

Once you’ve installed it, you’ll be presented with the following window prompting you to choose a configuration file:

objClean dialog window

As we already have a config file, we won’t need to download one, so we can skip the top section of the window. All that we need to do is add our project and then “Install Run Script”. This will add the objClean run script to all targets of your project, and then prompt you to open your project (or workspace if you have one). All that remains is for you to click “Build” and see the flood of warnings/errors!

The Good

  • You can share your styles with the team and commit them to your SCM.
  • Very easy to integrate.
  • Easy to change your config file either by going to the website or modifying it directly (it’s just a plist).
  • Offers a baseline standard from StackOverflow and the overall community.
  • As it integrates via a build step, you can configure precisely when check is run (e.g. only on a beta target, only when running your tests, every 10th build, etc.).
  • You can specify Class Prefixes to scan, so if you’re using some third party libraries that follow different coding standards, you can just ignore them.

The Bad

  • It doesn’t automatically make the changes for you.
  • Sometimes it will glitch causing false positives.

The Bottom Line

objClean is making a stand against poor coding style - a stand that Apple should be championing, but they aren’t. It’s a very commendable effort and overall I’m happy to use it on all new projects. However, it’s a real time sink to have to go through the entire project making these trivial changes manually, so for large existing projects, it could cost a days productivity to clear most of the warnings (note that due to the occasional glitch you won’t be able to clear all the warnings).