3 ms·
The thing I have missed the most with Objective C is the lack of a code tidy/formatting tool. All Xcode can do is alter the indent on each line which isn't use
by rogerbinns 14y ago
The thing I have missed the most with Objective C is the lack of a code tidy/formatting tool. All Xcode can do is alter the indent on each line which isn't useful. Regular indent etc do not support the language. There is an uncrustify tool in various SO answers but it is a good example of how not to do things (eg by default it does nothing - there are no presets, it is very flaky).
I wish Google provided tidy tools with their style guides, or Apple did something with Xcode.
- alxndr 14y agoHave you tried JetBrains's AppCode? http://www.jetbrains.com/objc/ http://www.jetbrains.com/objc/ (I haven't but their RoR-tailored IDE RubyMine is the only IDE I've enjoyed using after it for less than a week.)
- cageface 14y agoAppCode is brilliant. Best $99 I ever spent on a development tool. It's worth it for the refactoring and #import management alone.
- rogerbinns 14y ago> It's worth it for the refactoring and #import management alone. That is something Eclipse does out of the box! Apple really disappointed me with Xcode - it is actually less usable than Eclipse in my experience. This is not praise of Eclipse - it has many issues!
- coob 14y agoXcode has refactoring support.
- MBCook 14y agoIn my experience, it's extremely basic. Yes, it can rename a function or variable, but that doesn't compare to AppCode. AppCode can do both of those. Want to add a new parameter to a function? AppCode can do that, and put in a default value for you everywhere. Signature modifications are a snap. Plus it searches for possible references to the function you're modifying and can suggest fixes for them too. That alone is with the $99.
- rogerbinns 14y agoI haven't but I did look at the page as it was linked in the article. I never saw any mention of code formatting. An example of what I expect is like the Eclipse Source > Format option which will go in and make everything consistent including making lines less than 80 chars, adding space around operators (I never put in spaces which goes against almost every style guide), ensuring the arms of if/else always have braces etc. I actually do most of my iOS development by running emacs on my Linux box and using sshfs to access the files on the Mac. I use command line tools for compilation/running/debug. I did originally start out using Xcode but it gets in the way of the coding. (My work involves a library that functions in the background and has no user interface.) AppCode hasn't seemed worth the effort to investigate and $200 is rather a lot to spend on a code reformatter. (Also only running on MacOS makes it significantly less useful to me.)
- cageface 14y agoAppCode does exactly the kind of source cleanup you describe. It also manages #imports for you, has better code completion, provides a more useful debugger, and gives you refactoring tools almost as good as those available for Java. You can only do iOS dev on a Mac so I don't understand why you consider that an AppCode negative. Considering how much my time is worth as an iOS dev the $99 I spent for a personal license is probably the best software purchase I've ever made.
- rogerbinns 14y agoI'm doing development at a startup which means minimal funding and a $200 license. My main development system is running Linux and I do development of client side Android and iOS, plus server side (mostly Python), web, database etc. AppCode only helps for one of those, and would be more valuable to me if it ran on non-Mac platforms even just as a better Objective C editor. Note that I do do iOS dev on a Mac but I use a combination of emacs on my Linux box using sshfs and command line tools over ssh, plus Xcode when necessary. The product is a library with no user interface so this is actually more productive. In any event it looks like I should try AppCode. Hopefully it won't have the flaw that stopped me with Sublime Text 2. SL2 didn't detect when a file had been modified outside the editor (eg by vcs or different editor) and happily overwrote the modifications! I had briefly tried Xcode refactoring before giving up and using search/replace in emacs. One of the curses of multiple languages, client and server etc is that names sometimes end up wrong and need fixing to match local conventions.
- tszming 14y agoI am totally satisfied with Uncrustify, and this is my Uncrustify's config for Objective C, in case you find it useful (Allman style): https://gist.github.com/940977 https://gist.github.com/940977
- rogerbinns 14y agoIt took me about an hour to get uncrustify to actually work. Without a config file it makes no changes which is silly. I wanted it to modify the files inplace, and kept finding it creating numerous extra files but not actually making changes. Or sometimes it did but not again. I prefer my tools to be trustworthy, just work and not require babysitting.
- tszming 14y agoYou can use the Xcode "Run Script" build phases to automate the code format if you really need it (with Uncrustify's --no-backup option). I agree Xcode should have this feature by default, but speaking for Uncrustify - it is reliable and always produce consistent output format. Anyway, it also took me more than an hour to configure it :)
- rogerbinns 14y agoActually running uncrustify isn't a problem - I intended to make a shell script. What I wanted to do and have just work (HN won't let me use a literal asterisk so I used STAR): uncrustify --inplace STAR.h STAR.m I ended up having to download configs, deal with differences between the versions of uncrustify and configs, work out how to do inplace, get confused when it did it sometimes and not others, go "holy cow" when git showed all these extra files appearing (uncrustify does some sort of hashing scheme to avoid processing files seen before), trying to work out which files I could get rid of, finding it had put reformatted output in files with different extensions, trying to figure out what had happened, finding out that it doesn't autodetect headers as objc etc. And suspecting it may have problems if directories/files have spaces in their names. I know it can work. I just don't trust that it will always work.