Port of schuchert.wikispaces.com


iPhone.setup.xcode3

iPhone.setup.xcode3

The Video

Basic Application Setup

These notes are for XCode 3.2.2. Given that Apple has messed up Unit Testing in this version, you can assume these steps are fragile. If they fail for you, please send me an email (schuchert -at- yahoo -dot- com) and let me know the version of XCode you are using. I’ll see if I can figure it out. If you’ve solved the problem, let me know and I’ll update these notes. Or, if you are feeling ambitious, I’ll give you permission to update the notes.

Adding GH-Unit

What follows derives heavily from the gh-unit documentation.

Add a new Target

Add a first test

//
//  ItShouldHaveSmoke.m
//  Tutorial
//
//  Created by Brett Schuchert on 11/9/10.
//  Copyright 2010 Brett L. Schuchert. Use at will, just don't blame me.
//

#import <GHUnitIOS/GHUnitIOS.h>

@interface ItShouldHaveSmoke : GHTestCase {
    NSString *someVariableToInitialize;
}
@end

@implementation ItShouldHaveSmoke

-(void)setUp {
    someVariableToInitialize = @"Hello World";
}

-(void)tearDown {
    someVariableToInitialize = nil;
}

-(void)testThatItDoesHaveItsSmoke {
    GHAssertEquals(@"", someVariableToInitialize, nil);
}
@end
    GHAssertEquals(@"Hello World", someVariableToInitialize, nil);

Congratulations, you have your first test working.

Set Unit Test Executable Settings

Review GHUnitIOSTestMain.m/. Notice that it recommends editing your unit test executable and setting the following properties:

Property Name Default Value Recommended Setting
NSDebugEnabled NO YES
NSZombieEnabled NO YES
NSDeallocateZombies NO YES
NSHangOnUncaughtException NO YES
NSEnableAutoreleasePool YES NO
NSAutoreleaseFreedObjectCheckEnabled NO YES
GHUNIT_AUTORUN NO YES

Note, the last one is one I recommend. This will make your tests run automatically.

To make create these environment settings:

Now the hard part starts.

Now Really Setting Things Up

«to be expanded»

| Command-r | run application | | Command-b | quick open | | F3 | mapped to Edit:Find:Jump to Definition | | Command-alt up-arrow | Switch between .h and .m |


Comments

" Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.