How do I install uncrustify? I followed the instruction to install uncrustify but when I run it, it does not work. Can anyone give me some help installing this tool? I want to run it on objective-c code in xcode 4. Thanks in adavance
3 Answers
On OS X Mavericks 10.9.1 :
1- to install brew, open a terminal windows and type :
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
It will ask you to download some other files, answer OK for all (for more information see : http://brew.sh/index_fr.html).
2 - to install uncrusify, open a terminal windows an type :
brew install uncrustify
3 - to make your code beautiful, download BBUncrustifyPlugin-Xcode available at https://github.com/benoitsan/BBUncrustifyPlugin-Xcode
You will just have to :
- compile the project
- copy the file uncrusify.cfg in your home directory
- restart Xcode.
NB : With BBUncrustifyPlugin, you don't need to use Automator.
4 - After restarting Xcode, use the menu Edit > Uncrustify Selected Files to uncrustify the selected items in the project navigator.
Your code is now beautiful! That's magic!
post-scriptum : You can easily change your uncrusify configuration file by using :
- https://github.com/ryanmaxwell/UncrustifyX
- http://universalindent.sourceforge.net (better in my case)
I hope that this will help!

- 765
- 16
- 31
-
Since Xcode 8, plugins are no longer allowed. So BBUncrustifyPlugin-Xcode is deprecated. Instead, you can download this extension, written by yieldmo, available at https://github.com/yieldmo/uncrustifier, that will make the job for you. – Chrstpsln Feb 03 '17 at 17:16
Download zip On Windows, download the latest version of Uncrustify here: https://sourceforge.net/projects/uncrustify/files/latest/download
Extract zip The program is a standalone exe, so just extract the downloaded uncrustify-...-win32.zip file anywhere. For this example, I'll use C:\Uncrustify. So, the uncrustify.exe would be in that directory.
Add directory to PATH System Environment Variable In Windows 7+: Type Winkey + env - Select "Edit the system environment variables"
On the Advanced tab, click the Environment Variables button at the bottom. In the System variables section at the bottom, click the Path variable, then click the Edit... button.
Click the New button, and type C:\Uncrustify, or the directory that you extracted uncrustify.exe to.
Important: Click OK to close the dialog boxes or your change will not save. Verify
In a CMD window, typing where uncrustify should return the path to the uncrustify.exe.
In my case it shows C:\Uncrustify\uncrustify.exe Close Atom and reopen it. Now you should be able to atom-beautify and it will use Uncrustify to format your selection

- 1,470
- 2
- 18
- 32
I setup Uncrustify with Xcode 4 like so: http://blog.carbonfive.com/2011/03/10/code-formatting-in-xcode-4/
Can you explain what you tried to do, what you expected to happen, and how it didn't work?

- 17,918
- 1
- 43
- 70
-
I installed uncrustify using brew as per the git page install instructions. When I select some code to formant I got to services and then select uncrustify when I run the script I get this error: "The actions run schell script encountered an error" – lampShade May 11 '11 at 16:22
-
uncristify is installed in this locations: /usr/local/bin/uncrustify – lampShade May 11 '11 at 16:43
-
Ok, so if you run the same command from the terminal what error does it produce? Similarly have you confirmed that your service is able to get the correct text or file(s) from Xcode? – Jonah May 12 '11 at 00:09
-
I'm having the same problem. I believe it's related to the new liberals for NSArray and NSDictionary... Try formatting code without those and it works for me :( – Hackmodford Nov 12 '12 at 03:03