Showing posts with label xcode. Show all posts
Showing posts with label xcode. Show all posts

Friday, October 10, 2014

DerivedData and xcodebuild

If you use Xcode you know about DerivedData. If you don't know DerivedData, you don't know Xcode.

If you are setting up xcodebuilds from the command line, say for continuous build and integration (CI), then you want to make sure you are using that command line the best way possible. Some things I keep running into as I see people's build systems are:
  • Running out of space due to a backup of old DerivedData.
  • Build performance hanging, due to a backup of old DerivedData.
  • Unexplainable build failure, solved by deleting, you guessed it, DerivedData.

If you use the command line for builds then save yourself a lot of trouble in the future. Start using the xcodebuild option -derivedDataPath.

Here are the docs on it:
-derivedDataPath PATH                     specifies the directory where build products and other derived data will go

That one option huge significance. Here are some reasons why I use it and convert build systems over to this option:
  • I can store the DerivedData in the temporary source workspace of automated builds (like CI builds, automated test runs, etc.) When the workspace is cleaned up the DerivedData goes away and net disk space should be 0 at the end of the build.
  • With no shared DerivedData between builds the build performance does not drop due to large DerivedData folders.
  • Without a shared DerivedData folder I see much lower instances of unexplainable build errors. This means less cleanup, less build host reboots, etc.


Personally, I am very interested in how remote builds with Mac OS X Server and Xcode have improve the build process for automated builds. Until I get the chance to put such a system together, for now and for legacy build systems, I will use xcodebuild -derivedData to improve build systems I have to work with.

Friday, June 13, 2014

Xcode Code Snippets are Awesome

Image: Apple, Code Snippets
I am working on a project where I am writing a lot of test cases. I inherited a test suite that is far behind
the tests suites of the other platforms this project is supporting. As such I have been assigned to get the Mac and iOS test suites up to par with the other platforms.

So, as part of this I am adding a lot of test cases and that means a lot of new methods and chunks of similar code are being added. So, I finally have a good reason to use Xcode Code Snippets again and boy do they rock. I'd forgotten how helpful they are.

The best source for how to use Code Snippets in Xcode is the Apple docs.

I am using them to make a first pass through our test classes to add stub methods for all of the missing test cases that are on other platforms. No cut and paste, with the shortcut I added "misstest", I just start to write misstest and the code completion option comes up and I can drop in a new missed test block of code.

Then I just go through and edit each one with the new test case by porting the tests from other platforms into the Mac and iOS test cases. The snippet also allows me to customize a test case snippet for the additional setup we do like stubbed log statements, test naming convention, etc.

It is a great little optimization to get more done with less typing and cut/pasting.

Try it out if you have something repetitive you need to write.