Running Unit Tests from the Command Line
This is, unfortunately, not properly supported. There are a few hacks to get this to work, including the one mentioned here:
The solution recommended here, however, is to modify a system script, which is not something I usually like to do.
Instead here are the steps I followed:
- Create a new scheme called RunTests based on your unit test target (or whatever you'd like)
- Edit the Scheme and click on the Build action. Make sure that your test has "Run" checked
- Remove the Test Host setting from the target's build settings.
- (optional) Uncheck "Output Environment Variables" from the Run Script Build Phase for running the tests
Then run this in Terminal:
xcodebuild -workspace MyWorkspace.xcworkspace -sdk iphonesimulator TEST_AFTER_BUILD=YES clean build
If you get an error about "No active architectures", then you can add
Once this works, you can use the gist linked above.