Xcode static library project template with unit testing
Xcode by default has a project template for creating static libraries, these are quite useful for creating standardized code which you can use in various different projects. They can also be used to keep a separation between your user interface code and your logic code.
One thing that Xcode doesn’t supply out of the box are project templates which include a testing framework completely setup. To this end i modified the default static library project template to include the testing framework of Google Toolkit For Mac. Simple start a new project using this template and it is all setup, you only need to add your own logic code and create tests classes for them.
Download
Cocoa Touch Static Lib. With Unit Testing (122)
Installation
Installing the template is very simple, all you need to do is extract the archive within the user template folder:
/Library/Application Support/Developer/Shared/Xcode/Project Templates/{Category}
The category is a folder with a descriptive name, this name will be presented to you within the New Project window of Xcode. You need to extract the archive within the category folder.
How to get started
After installation you can start Xcode, go to File -> New Project to open up the new project wizard. In the New Project there should be a new category in the left bar with the name you specified earlier, select this category. Now you should see a new template with the name Cocoa Touch Static Lib. With Unit Testing.
When the project is created there will be a number of folders presented, in the top part of your project is a document called How to use this project.rtf read this document along with the About the Classes group.rtf (within the classes folder) and the About the Tests group.rtf within the Tests folder. (these a very small but they will get you started).
By default there is a Calculator class example containing some application logic and a CalculatorTest class to test this logic, if you perform a build and take a look at the Build Results tab you can see the test resul similair ts, which will look to:
Executed 2 tests, with 0 failures (0 unexpected) in 0.188 (0.188) seconds
Where to go from here
If you want to use static libraries but you have no clue on how to use them with a normal iPhone project then please read the following which will explain it all:
Xcode: The complete explanation on how to use static libraries.
If you want to modify the the template yourself but you don’t know how, please read the following which will explain it all:
Xcode: How to customize the existing project templates
Version Information
Version 1.0
Integration with Google Toolkit For Mac
Sample class with sample test class
Recent Comments