Giter Club home page Giter Club logo

iphone-static-library-project-template's Introduction

Currently the only way to create re-usable code amongst different projects for the iPhone platform is to create static libraries. Frameworks (as in Mac OS X) are not supported in the iPhone SDK. Also setting up unit testing, which is a crucial part of building re-usable libraries of course, is not that trivial.

This project consists of 2 pieces:

* Project Template for creating static libraries with built-in support for unit testing.
* File Template for creating unit test files.

INSTALLATION:
---------------
The user defined project and file templates in XCode are stored in the following path:

   ~/Library/Application Support/Developer/Shared/Xcode

You will be installing everything under the above path.

To install the project template: 
* Create a folder called "Project Templates" if it does not already exist.
* Create a subfolder under that for categorization. The name of this folder is what is going to show in the "New Project" dialog under "User Templates". 
* Copy the contents of ProjectTemplate (from github) under that subfolder, you just created.

To install the file template:
* Create a folder called "File Templates" if it does not already exist
* Create a subfolder under that for categorization. The name of this folder is what is going to show in the "New File" dialog under "User Templates". 
* Copy the contents of FileTemplate (from github) under that subfolder, you just created.

USAGE:
------

When you want to create a new static library, select "New Project" in XCode and simply select the template you just installed. (Found under the custom sub folder name, under user templates)

The project has the following structure:

* GoogleToolbox group: This is where the necessary files for unit testing is stored. This is a snapshot of the latest Google Toolbox For Mac (GTM) project (http://code.google.com/p/google-toolbox-for-mac/) from the SVN trunk. Note that the 1.5.1 version available from the downloads section had a nasty bug where every unit test error is duplicated. It is fixed in the trunk, and I included that in this project. From time to time you can go to the GTM project site and get the latest and greatest and copy those manually in your template as well.

* UnitTests group: This is where the unit test files will go. To add a new unit test file, select Add->"New File" and select the "Unit Test Case class" template under user templates. The test template comes with the necessary import directives that imports GTMSenTestCase and OCMock header files. Each method in the test template must begin with "test". E.g. testMethod1. Links to the OCMock and GTM project sites are also included in the template for further instructions. The unit test files do not have a corresponding .h file. The interface definition is included inline with the .m file for brevity.

* Source group: This is where your actual source files live.

* Frameworks: OCMock framework is embedded in the project. The other necessary frameworks are linked to.

* Targets: There are 2 targets. One is the project target which will be the static library that you will be building. The second one is the unit test target named "UnitTest". Make sure that all unit test files are only added to this target and not to the static library target, when you create a new unit test file.  

To run the unit tests, you can select the Active Target to be the UnitTest target and hit CMD+B. This will run all the unit tests you have created. Note that when running the unit tests, the IPhone Simulator needs to be closed. If the IPhone Simulator is running you will get an error, and this is a restriction of the GTM suite at the moment of writing.

To debug the unit tests, you can select "Build and Debug", and you will be able to hit breakpoints in your unit test files.

Make sure you add the source files that you will be unit testing to the UnitTest target as you create them.

There is also a drop-in replacement for NSLog included in this template. It is taken directly from http://iPhoneIncubator.com/blog/debugging/the-evolution-of-a-replacement-for-nslog.

See below for further info:

http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting

http://blog.carbonfive.com/2009/02/testing/iphone-unit-testing-toolkit





iphone-static-library-project-template's People

Contributors

keremk avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.