104
K2JQPG &GXGNQROGPV )WKFG &GXGNQROGPV 'PXKTQPOGPVU :EQFG

iPhone Development Guide

Embed Size (px)

Citation preview

Page 1: iPhone Development Guide
Page 2: iPhone Development Guide
Page 3: iPhone Development Guide
Page 4: iPhone Development Guide
Page 5: iPhone Development Guide
Page 6: iPhone Development Guide
Page 7: iPhone Development Guide

CFBundleIdentifierCFBundleIdentifier

Page 8: iPhone Development Guide

main.mHelloWorldAppDelegate.hHelloWorldAppDelegate.mMyView.hMyView.m

Page 10: iPhone Development Guide

Page 11: iPhone Development Guide
Page 12: iPhone Development Guide

Page 13: iPhone Development Guide

Groups & Files list

Detail view

Toolbar

Favorites bar

Status bar

Page 14: iPhone Development Guide

Page 15: iPhone Development Guide

UIFont

UIFont

Page 16: iPhone Development Guide
Page 17: iPhone Development Guide

<Xcode>/Applications

Page 18: iPhone Development Guide

<Xcode>

HelloWorld

MyView

Page 19: iPhone Development Guide

MyView.m

Page 20: iPhone Development Guide

HelloWorldAppDelegate MyView

HelloWorldAppDelegate.m

HelloWorldAppDelegate

#import

#import "MyView.h"

applicationDidFinishLaunching:

MyView *view = [[MyView alloc] initWithFrame:[window frame]];[window addSubview:view];

Page 21: iPhone Development Guide

[view release];

HelloWorldAppDelegate.m

#import "HelloWorldAppDelegate.h"#import "MyView.h"

@implementation HelloWorldAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {

// Override point for customization after app launch MyView *view = [[MyView alloc] initWithFrame:[window frame]]; [window addSubview:view]; [view release];

[window makeKeyAndVisible];}

- (void)dealloc { [window release]; [super dealloc];}

@end

drawRect: MyView.m

- (void) drawRect:(CGRect) rect { NSString *hello = @"Hello, World!"; CGPoint location = CGPointMake(10, 20); UIFont *font = [UIFont systemFontOfSize:24]; [[UIColor whiteColor] set]; [hello drawAtPoint:location withFont:font];}

CGPointM

10

20

;

Page 22: iPhone Development Guide

Building ... — 2 errors Compiling <project_directory>/Classes/HelloWorldAppDelegate.m (2 errors) error: 'MyView' undeclared (first use in this function) error: 'view' undeclared (first use in this function)

#import "MyView.h"

HelloWorldAppDelegate.m

Page 23: iPhone Development Guide
Page 24: iPhone Development Guide
Page 25: iPhone Development Guide

Page 26: iPhone Development Guide

Page 27: iPhone Development Guide

Page 28: iPhone Development Guide

Entitlements.plist

Page 29: iPhone Development Guide

TARGET_OS_IPHONETARGET_IPHONE_SIMULATOR

TARGET_IPHONE_SIMULATOR

// Set hello to "Hello, <device or simulator>"!#if TARGET_IPHONE_SIMULATOR NSString *hello = @"Hello, iPhone Simulator!";#else NSString *hello = @"Hello, iPhone device!";#endif

Page 30: iPhone Development Guide

TARGET_OS_IPHONE

#if TARGET_OS_IPHONE #import <UIKit/UIKit.h>#else #import <Cocoa/Cocoa.h>#endif

TARGET_OS_IPHONE TARGET_IPHONE_SIMULATORTargetConditionals.h

-framework <framework_name>

Page 31: iPhone Development Guide

.zipHelloWorld.zip

HelloWorld

Page 32: iPhone Development Guide

.xcodeprojHelloWorld.xcodeproj

Page 33: iPhone Development Guide
Page 34: iPhone Development Guide

Page 35: iPhone Development Guide

armv6 armv7

Page 36: iPhone Development Guide

MinimumOSVersionInfo.plist

Page 37: iPhone Development Guide

Page 38: iPhone Development Guide

<Xcode>/Platforms/iPhoneSimulator.platform/SDKs/.../usr/include

#import/#include

Code Signing Identity 'iPhone Developer' does not match any valid, non-expired, code-signing certificate in your keychain.

Page 39: iPhone Development Guide

CFBundleIdentifiercom.<organization_name>.* CFBundleIdentifier

com.<organization_name>.<application_name>CFBundleIdentifier

CFBundleIdentifier

com.mycompany.*

com.mycompany.MyAppCFBundleIdentifier

CFBundleIdentifier

com.mycompany.MyApp.*

com.mycompany.MyAppCFBundleIdentifier

CFBundleIdentifier

Page 40: iPhone Development Guide

~/Library/ApplicationSupport/iPhone Simulator/User/Applications

Applications

Page 41: iPhone Development Guide
Page 42: iPhone Development Guide
Page 43: iPhone Development Guide

Page 44: iPhone Development Guide

Page 45: iPhone Development Guide

Page 46: iPhone Development Guide

~/Library/Application Support/iPhone Simulator/User

<iPhoneUserDomain>

<iPhoneUserDomain>/Library/Preferences

<iPhoneUserDomain>/Applications/<app_UUID>Library/Preferences

Page 48: iPhone Development Guide

Provisioning Profile(is stored on device)Development Certificate

(is stored on computer)Development certificates

Device identifiers

App ID

Digital identity

Public key

Computer

Certificate Signing Request

Keychain

Xcode Organizer

iPhone Developer Program Portal

Page 49: iPhone Development Guide

GFWOTNXFIY.com.mycompany.MyApp

GFWOTNXFIY.com.mycompany.myappsuite.*

Page 50: iPhone Development Guide
Page 51: iPhone Development Guide

/Applications/Utilities

Page 52: iPhone Development Guide
Page 54: iPhone Development Guide
Page 55: iPhone Development Guide

.p12

iPhoneDeveloper Identity Documents

/Applications/Utilities

iPhone Developer Identity Documents

iPhone Developer Identity Documents.dmg

Page 56: iPhone Development Guide
Page 57: iPhone Development Guide

Debugger strip

Debugger datatip

Gutter

Page 58: iPhone Development Guide

NSLog

/Applications/Utilities

Page 59: iPhone Development Guide

2008-10-03 18:10:39.933 HelloWorld[1026:20b] *** -[GSFont ascender]: message sent to deallocated instance 0x126550

Page 60: iPhone Development Guide

NSZombieEnabled YES

NSZombieEnabled

Page 62: iPhone Development Guide

SenTestCase

LogicTests

LogicTests

Page 63: iPhone Development Guide

LogicTests.h

#import <SenTestingKit/SenTestingKit.h>#import <UIKit/UIKit.h>

@interface LogicTests : SenTestCase {}@end

LogicTests.m

#import "LogicTests.h"

@implementation LogicTests- (void) testFail { STFail(@"Must fail to succeed.");}@end

Page 64: iPhone Development Guide

LogicTest.m

#import "LogicTests.h"

@implementation LogicTests- (void) testPass { STAssertTrue(TRUE, @"");}@end

<application_name>Testing

<application_name>Tests

Page 65: iPhone Development Guide
Page 66: iPhone Development Guide

MyAppTests.octest

MyAppTests

Page 67: iPhone Development Guide

MyAppTests.h

#import <SenTestingKit/SenTestingKit.h>#import <UIKit/UIKit.h>

@interface MyAppTests : SenTestCase {}@end

MyAppTests.m

#import "ApplicationTests.h"

@implementation ApplicationTests- (void) testFail { STFail(@"Must fail to succeed.");}@end

Page 68: iPhone Development Guide

MyAppTests.m

#import "MyAppTests.h"

@implementation LogicTests- (void) testAppDelegate { id app_delegate = [[UIApplication sharedApplication] delegate]; STAssertNotNil(app_delegate, @"Cannot find the application delegate.");}@end

Page 69: iPhone Development Guide

test... void

- (void) test<test_case_name> { ... // Set up, call test-case subject API. ST... // Report pass/fail to testing framework. ... // Tear down.}

setUp tearDown void

setUp/tearDown

- (void) setUp { test_subject = [[MyClass new] retain]; STAssertNotNil(test_subject, @"Could not create test subject.");}

- (void) tearDown { [test_subject release];}

Page 70: iPhone Development Guide

setUp tearDown

Page 71: iPhone Development Guide

Page 72: iPhone Development Guide

Page 73: iPhone Development Guide

Page 74: iPhone Development Guide

<Xcode>/Applications <Xcode>

Page 75: iPhone Development Guide

Tester

iTunes

Developer Program Portal

Tester DeviceTester device ID Tester device ID Tester device

Testerprovisioning profile

Test app ID

Tester device

Developmentcertificate

Testerprovisioning profile

Test app archive

Test application

Testerprovisioning profile

Test app archive

Test application

Testerprovisioning profile

Page 76: iPhone Development Guide
Page 77: iPhone Development Guide

iTunesArtwork

iTunesArtwork

Page 78: iPhone Development Guide

<application_name> for <user_name>.zip MyTestApp forAnna Haro.zip

Page 79: iPhone Development Guide
Page 80: iPhone Development Guide

.mobileprovision

.app

~/Library/Logs/CrashReporter/MobileDevice

<application_name> crash logs from <your_name> MyTestApp crash logsfrom Anna Haro

<user_name>

C:\Users\<user_name>\AppData\Roaming\Apple computer\Logs\CrashReporter/MobileDevice

Page 81: iPhone Development Guide

C:\Documents and Settings\<user_name>\Application Data\Apple computer\Logs\CrashReporter

<application_name> crash logs from <your_name>MyTestApp crash logs from Anna Haro

Page 82: iPhone Development Guide
Page 83: iPhone Development Guide

-ObjC-all_load

Page 84: iPhone Development Guide
Page 85: iPhone Development Guide

main.m

// main.m#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal;}

HelloWorldAppDelegate.h

// HelloWorldAppDelegate.h#import <UIKit/UIKit.h>

@interface HelloWorldAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window;}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

HelloWorldAppDelegate.m

// HelloWorldAppDelegate.m#import "HelloWorldAppDelegate.h"#import "MyView.h"

@implementation HelloWorldAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {

// Override point for customization after application launch MyView *view = [[MyView alloc] initWithFrame:[window frame]]; [window addSubview:view]; [view release];

[window makeKeyAndVisible];}

Page 86: iPhone Development Guide

- (void)dealloc { [window release]; [super dealloc];}

@end

MyView.h

// MyView.h#import <UIKit/UIKit.h>

@interface MyView : UIView {}

@end

MyView.m

// MyView.m#import "MyView.h"

@implementation MyView

- (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self;}

- (void)drawRect:(CGRect)rect { NSString *hello = @"Hello, World!"; CGPoint location = CGPointMake(10, 20); UIFont *font = [UIFont systemFontOfSize:24]; [[UIColor whiteColor] set]; [hello drawAtPoint:location withFont:font];}

- (void)dealloc { [super dealloc];}

@end

Page 87: iPhone Development Guide

SenTestCase.h

STFail(failure_description, ...)

failure_description

nil

...

failure_description

STAssertEqualObjects(object_1, object_2, failure_description, ...)

Page 88: iPhone Development Guide

object_1

object_2

failure_description

nil

...

failure_description

[object_1 isEqualTo:object_2]

STAssertEquals(value_1, value_2, failure_description, ...)

value_1

value_2

failure_description

nil

...

failure_description

value_1 value_2

Page 89: iPhone Development Guide

STAssertEqualsWithAccuracy(value_1, value_2, accuracy, failure_description, ...)

value_1

value_2

accuracy

failure_description

nil

...

failure_description

value_1 value_2 accuracy

STAssertNil(expression, failure_description, ...)

expression

failure_description

nil

...

failure_description

Page 90: iPhone Development Guide

STAssertNotNil(expression, failure_description, ...)

expression

failure_description

nil

...

failure_description

STAssertTrue(expression, failure_description, ...)

expression

failure_description

nil

...

failure_description

STAssertFalse(expression, failure_description, ...)

Page 91: iPhone Development Guide

expression

failure_description

nil

...

failure_description

STAssertThrows(expression, failure_description, ...)

expression

failure_description

nil

...

failure_description

STAssertThrowsSpecific(expression, exception_class, failure_description, ...)

expression

exception_class

Page 92: iPhone Development Guide

failure_description

nil

...

failure_description

expression exception_class

STAssertThrowsSpecificNamed(expression, exception_class, exception_name, failure_description, ...)

expression

exception_class

exception_name

failure_description

nil

...

failure_description

expression exception_classexception_name

STAssertNoThrow(expression, failure_description, ...)

Page 93: iPhone Development Guide

expression

failure_description

nil

...

failure_description

STAssertNoThrowSpecific(expression, exception_class, failure_description, ...)

expression

exception_class

failure_description

nil

...

failure_description

expression exception_class

STAssertNoThrowSpecificNamed(expression, exception_class, exception_name, failure_description, ...)

expression

Page 94: iPhone Development Guide

exception_class

exception_name

failure_description

nil

...

failure_description

expression exception_classexception_name

STAssertTrueNoThrow(expression, failure_description, ...)

expression

failure_description

nil

...

failure_description

STAssertFalseNoThrow(expression, failure_description, ...)

expression

Page 95: iPhone Development Guide

failure_description

nil

...

failure_description

Page 96: iPhone Development Guide
Page 97: iPhone Development Guide

<Xcode>/Platforms/iPhoneSimulator.platform/Developer/SDKs/<SimulatorSDK>/System/Library/Frameworks<Xcode> <SimulatorSDK>

cblasvDSP vv

Accelerate.framework

ABAddressBook.framework

ABAddressBookUI.framework

Page 98: iPhone Development Guide

Application-Services.framework

AU AudioAudioToolbox.framework

AU AudioAudioUnit.framework

AVAVFoundation.framework

AE AH ASAX CM FCHI HM HRIB ICA KCKL LM NavNM OSA PMSec SndSPB SR TETSM TXNURL

Carbon.framework

CFCFNetwork.framework

AudioCoreAudio.framework

NSCoreData.framework

CFCoreFoundation.framework

CGCoreGraphics.framework

CLCoreLocation.framework

CFCoreServices.framework

Disk-Arbitration.framework

Page 99: iPhone Development Guide

EAExternal-Accessory.framework

NSFoundation.framework

GKGameKit.framework

IOKit.framework

JavaVM.framework

IOKernel.framework

MKMapKit.framework

MPMediaPlayer.framework

MFMessageUI.framework

UTMobileCore-Services.framework

AL alOpenAL.framework

GL glOpenGLES.framework

CAQuartzCore.framework

Page 100: iPhone Development Guide

HI ICM MCNA QT QTSQTVR RTPRSG ST TCVD VR

QuickTime.framework

CSSM SecSecurity.framework

SKStoreKit.framework

SCSystem-Configuration.framework

UIUIKit.framework

/usr/lib.dylib /usr/include

<Xcode>/Platforms/iPhoneOS.platform/Developer/SDKs/<iPhoneSimulatorSDK>/usr/lib<Xcode> <iPhoneSimulatorSDK>

<Xcode>/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib

<Xcode>/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/include

Page 101: iPhone Development Guide

GFWOTNXFIY.com.mycompany.MyApp

Page 102: iPhone Development Guide

test...

Page 103: iPhone Development Guide
Page 104: iPhone Development Guide