Some notes and pictures to remind me how to do this in XCode.

Create a new command line project.

how-to-setup-blank-osx-project-with-unit-tests1

Hit that ‘+’ sign in the lower left hand corner to add a new target.

how-to-setup-blank-osx-project-with-unit-tests2

Create a Test Bundle target.

how-to-setup-blank-osx-project-with-unit-tests3

Give it a name

how-to-setup-blank-osx-project-with-unit-tests4

Now connect your project to the test target by editing your scheme
how-to-setup-blank-osx-project-with-unit-tests5

Clicking the Unit Test section,

how-to-setup-blank-osx-project-with-unit-tests6

how-to-setup-blank-osx-project-with-unit-tests7

And then selecting your newly created test target.

how-to-setup-blank-osx-project-with-unit-tests8

Should now look something like this.

how-to-setup-blank-osx-project-with-unit-tests9

Should now be able to go Command+U, run your tests and all should be good.

how-to-setup-blank-osx-project-with-unit-tests10

If you get an error message (linkage error) that looks something like this

error

It’s because we need to do this annoying thing, which is flag each class we want to be accessible in our test suite.
Goto the offending file that can’t be found, and on the right hand side open you options slider, and tick the ‘Test’ Target relationship. That will make your project file available to your tests.

add-test