2

Some colleagues, now departed, had the habit of adding new classes within a related class file.

This makes refactoring painful.

Is there a tool, perhaps within XCode or AppCode or just a simple script, that will split up these monster files?

alex bird
  • 134
  • 4

2 Answers2

2

It appears there is a tool to help with this in AppCode, but it only semi-automates the process.

I'm using AppCode 2.0, I don't know if the same tool is available in AppCode 1.x.

To extract one class from a file to a new file, right-click the@interface or @implementation line and select Refactor > Move. Alternatively press F6 on that line. You can now enter a new file name, though you probably want to copy+paste the class name in here. At this point you can also select any defines you want to move.

I have done some work on a script to extract all classes in a file. I'd love to share this one day, when I get the chance to remove our clients code from the unit tests!

alex bird
  • 134
  • 4
0

I don't think so there is any tool for this. However you can write your own osx application for doing the same.

The application will ask to browse the file, and it will search for @interface....@endand@implementation....~@end` and will create a file from this. If a single file contains two classes then it will result in for files (two headers and two implementation). Then the original file can be deleted manually or automatically.

I think this above task can be completed in few hours.

Here you can go for save the original file in a folder, just in case you want to rollback.

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • 1
    This isn't really an answer. It ignores the complexities of managing defines and includes, not to mention protocols. Also this is really not a candidate for a GUI application at all. The last line "Here you can go for save the original file in a folder, just in case you want to rollback." is a bit worrying. We use a revision control system. There is no need to back up bits of code in other ways. – alex bird Mar 28 '13 at 10:55
  • @alexbird: Yes I agree, There is SVN and RCS are there. But in older XCode's it was missing. – Anoop Vaidya Mar 29 '13 at 03:41
  • Anoop - You don't need to have revision control built into XCode. There are many GUIs for them, and of course the command line. – alex bird May 25 '13 at 23:34