Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TheBSDGuy

macrumors 6502
Original poster
Jan 24, 2012
319
29
I started noticing our drive space was disappearing at an alarming rate. On checking the size of some of our project directories, even tiny projects are running greater than 800MB.

Is there some command I can use to "clean" one of these projects after development is done? It looks like a lot of it is from tmp files.
 

zeppenwolf

macrumors regular
Nov 17, 2009
129
3
> Is there some command I can use to "clean" one of these projects after development is done?

Well, yes, there is the, er, "Clean" command. In my current Xcode, it's Shift-Command-K.

Additionally, you might consider doing what I do-- I keep source files and build files completely separate. The default is that XCode creates a "build" directory inside your current project folder, where all your source files are. This makes no sense to me.

I always adjust my "Build Projects Path" in the Project's Build settings to go to a disposable location; in my case I have an entire partition of the drive devoted to temporary files, so, for MyKillerApp, all build files are generated in "Volumes/temp/builds/MyKillerApp".
 
  • Like
Reactions: ArtOfWarfare

weichsel

macrumors newbie
May 23, 2013
15
6
Note that when you hold down the option key while you choose the "Product" menu item, the "Clean" command will become "Clean Build Folder". This will wipe the entire "Build" directory and not only "Product, Intermedidates, etc.".
 

szymczyk

macrumors regular
Mar 5, 2006
187
17
>
Additionally, you might consider doing what I do-- I keep source files and build files completely separate. The default is that XCode creates a "build" directory inside your current project folder, where all your source files are. This makes no sense to me.

Apple moved the default build location out of the project folder in Xcode 4. The default Xcode build location is the following directory:

/Users/YourUsername/Library/Developer/Xcode/DerivedData​

You shouldn't have to do anything to keep your build files separate from your source files. If you're using a recent version of Xcode and Xcode is using the project folder as the build location, you can change the default build location for new projects from Xcode's Locations preferences. You can change the build location for an existing project by choosing File > Project Settings.
 

Toutou

macrumors 65816
Jan 6, 2015
1,082
1,575
Prague, Czech Republic
On a similar note - is this really necessary/is it ok? Ten gigs, that's a helluva IDE.
Snímek obrazovky 2016-02-04 v 23.28.54.png
 

TheBSDGuy

macrumors 6502
Original poster
Jan 24, 2012
319
29
When I wrote this post I shouldn’t have used the word “clean” in it. Maybe “strip” might be a better word.

Here’s the problem:

As an example, we have one project that has a main module and 5 nib files. When we compile all this stuff, the overall size of the main build folder is close to 1GB. The source code isn’t huge, maybe about 500K, and the xib files aren’t huge or overly complicated. When the compiled product is fully assembled into an actual app, the size of it (with all nib/xib files…everything) isn’t too big, maybe about 12MB.

What I would like to do is completely strip out all the junk leaving the complied app and nib files, source code, xib, and project files, so that when we’re done developing if we ever need to go back and rebuild or update code all we need to do is modify whatever code needs modification and then recompile, and then once a again when done, strip out all the rubbish.

I’ve tried this with even simple apps, and even they seem to be using close to 800MB of space each.

If this keeps up we’re going to have to go out and buy a bunch of huge drives just to do basic development. There has to be a better way!

By the way, thanks for the input so far. It’s given me some ideas.
 

Red Menace

macrumors 6502a
May 29, 2011
583
230
Colorado, USA
As mentioned earlier, current versions of Xcode place the build stuff (which includes various intermediate and debug data) in the DerivedData folder in your user's ~/Library/Developer/Xcode folder, so after testing you can perform an archive build, move the finished product somewhere and then delete the build folder.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,995
8,878
A sea of green
First you need to discover what's strippable as "rubbish" in your project folders.

If it's derived data, then edit the project so Xcode puts the derived data outside the project folder. Other posts have already described how to do that.

If it's not derived data, then you need to dissect one of your project folders, and figure out what's taking up the space. The 'du' command may help. Try this command, replacing PATH_TO_PROJECT with the correct pathname to a project folder.
Code:
du -h PATH_TO_PROJECT

If you want an interpretation on what 'du' is telling you, post the complete output (copy and paste from the Terminal window). You can also read the man page for 'du' and interpret the output yourself.

There are also various GUI tools that can help you find where disk space is being used. Examples include DaisyDisk, OmniDiskSweeper, GrandPerspective, and others.

Once you know where the rubbish is located within a project folder, you can formulate a command-line to remove it. This could be probably done as an Automator application with a suitable Run Shell Script that removes the "rubbish" items for a project folder dropped on it. If you need help with that, ask again, and make sure to tell us what the sub-folder is where the rubbish is located.
 

firewood

macrumors G3
Jul 29, 2003
8,140
1,384
Silicon Valley
What I would like to do is completely strip out all the junk leaving the complied app and nib files, source code, xib, and project files, so that when we’re done developing if we ever need to go back and rebuild or update code all we need to do is modify whatever code needs modification and then recompile, and then once a again when done, strip out all the rubbish.

That's easy. Put the source code, resources, xib and project files under source control on a remote server (svn, git or maybe even github), build, and copy the resulting compiled app bundle into your Applications directory. Then you can deleted everything, source folder, any build directories or derived data, and have nothing left in your user account (except maybe the app). Check the project out from source control if you need to go back and work on the app. Also, make sure your source repository gets backed-up.
 

zeppenwolf

macrumors regular
Nov 17, 2009
129
3
Apple moved the default build location out of the project folder in Xcode 4. The default Xcode build location is the following directory:

/Users/YourUsername/Library/Developer/Xcode/DerivedData​

You shouldn't have to do anything to keep your build files separate from your source files. If you're using a recent version of Xcode and Xcode is using the project folder as the build location, you can change the default build location for new projects from Xcode's Locations preferences. You can change the build location for an existing project by choosing File > Project Settings.

"In xcode 4" ?

Our experiences differ, then. I am using several versions of Xcode, depending on system version, for backward compatibility. But, for example, in Xcode 5.1.1, if I create a brand new project "CiaoWorld", then XCode creates a "build" folder inside the ${Project} folder, which is to say that it creates and uses "CiaoWorld/build/" not to mention "CiaoWorld/CiaoWorldTests"

In terms of source control, these are nothing more than pollution.

You shouldn't have to do anything to keep your build files separate from your source files.

Well on that we are in agreement. :)
 

TheBSDGuy

macrumors 6502
Original poster
Jan 24, 2012
319
29
What I was hoping for was some command or sequence that I missed that would strip the stuff out. Clearly this needs to be a job done by custom shell scripts, which is what I'll probably do. Thanks to all for the input anyway.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.