Logo 61e73bc61c0e1780102320e879dc3cac0e29303ea8894dd8f10c942f3ba8120f


An adorable little blog

XCTest In Command Line Applications

Tuesday — June 16th, 2015

XCTest is a handy dandy way to test your iOS and Mac apps. Xcode even sets up some sample tests and a test target for free when you create a new Objective-C or Swift app.

That is, unless you wanted to create a Command Line Tool. Then Xcode 6 tells you to go to hell.

If you want your Command Line Tool to get the chance to sit at the cool-kid table you have to add the Tests in manually.

No big deal, right?

Let's just create a new project.


Select Command Line Tool


Then get the Project Inspector pulled up in the Navigator.


We'll just add ourselves a fancy new Target to our application

Then we can select a Cocoa Testing Bundle.

Finally we'll just choose the Target we want to test and......

Oh. Well then. Screw you too, Xcode. I really wanted to select that target to be tested, but I guess I'll have to do it the old-fashioned way.

Roll up your sleeves, we need to select the active scheme at the top-left of Xcode and Edit it.

Edit Scheme

When we get that pulled up we need to select the Test phase and click the tiny + at the bottom-left to add some tests.

Then we can select our test bundle and add it.

And would you look at that! We have tests in our project!

Now we can cross our fingers and hit Command + U to run our new tests.


Boom. Done. We passed the tests with flying colors and we didn't even study the night before.