Thursday, January 29, 2009

How to skip provisioning profile for iPhone SDK 2.2.1 (build 9M2621a)

The trick to skip provisioning profile for iPhone SDK 2.1.1 (build 9M2621a) still works

Just backup and edit the file and add the magic words as shown below highlighted in red color

/Developer/Platforms/iPhoneOS.platform/Info.plist

Info.plist:Select all

<key>OverrideProperties</key>
<dict>
<key>CODE_SIGN_CONTEXT_CLASS</key>
<string>XCiPhoneOSCodeSignContext</string>
<key>DEBUG_INFORMATION_FORMAT</key>
<string>dwarf-with-dsym</string>
<key>EMBEDDED_PROFILE_NAME</key>
<string>embedded.mobileprovision</string>
<key>SDKROOT</key>
<string>iphoneos2.2.1</string>
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>

</dict>


Please remember to restart your Xcode after the amendment above.

For MobileInstallation patch, please use my package (updated to support firmware 2.2.1) as posted here
http://hackint0sh.org/forum/showpost.php?p=340693&postcount=14

Related articles from this blog
http://iphonesdkdev.blogspot.com/2008/11/how-to-skip-provisioning-profile-for.html
http://iphonesdkdev.blogspot.com/2008/09/xcode-template-for-pwned-iphone-device.html




Sunday, January 25, 2009

Objective C 2.0, Foundation Framework Quick Reference






Data Type Conversion Rules
The Objective-C compiler adheres to very strict rules when it comes to evaluating expressions that consist of different data types.

The following summarizes the order in which conversions take place in the evaluation of two operands in an expression:

1. If either operand is of type long double, the other is converted to long double, and that is the type of the result.

2. If either operand is of type double, the other is converted to double, and that is the type of the result.

3. If either operand is of type float, the other is converted to float, and that is the type of the result.

4. If either operand is of type _Bool, char, short int, or bit field,[1] or of an enumerated data type, it is converted to int.

5. If either operand is of type long long int, the other is converted to long long int, and that is the type of the result.

6. If either operand is of type long int, the other is converted to long int, and that is the type of the result.

7. If this step is reached, both operands are of type int, and that is the type of the result.
































Common NSString Methods
MethodDescription
+(id) stringWithContentsOfFile: path encoding: enc error: err Creates a new string and sets it to the path contents of a file specified by path using character encoding enc, returning error in err if non-nil
+(id) stringWithContentsOfURL: url encoding: enc error: err Creates a new string and sets it to the contents of url using character encoding enc, returning error in err if non-nil
+(id) string Creates a new empty string
+(id) stringWithString: nsstring Creates a new string, setting it to nsstring
-(id) initWithString: nsstring Sets a newly allocated string to nsstring
-(id) initWithContentsOfFile: path encoding: enc error: err Sets a string to the contents of a file specified by path
-(id) initWithContentsOfURL: url encoding enc error: err Sets a string to the contents of url (NSURL *) url using character encoding enc, returning error in err if non-nil
-(NSUInteger) length Returns the number of characters in the string
-(unichar) characterAtIndex: i Returns the Unicode character at index i
-(NSString *) substringFromIndex: i Returns a substring from the character at i to the end
-(NSString *) substringWithRange: range Returns a substring based on a specified range
-(NSString *) substringToIndex: i Returns a substring from the start of the string up to the character at index i
-(NSComparator *) caseInsensitiveCompare: nsstring Compares two strings, ignoring case
-(NSComparator *) compare: nsstring Compares two strings
-(BOOL) hasPrefix: nsstring Tests whether a string begins with nsstring
-(BOOL) hasSuffix: nsstring Tests whether a string ends with nsstring
-(BOOL) isEqualToString: nsstring Tests whether two strings are equal
-(NSString *) capitalizedString Returns a string with the first letter of every word capitalized (and the remaining letters in each word converted to lower case)
-(NSString *) lowercaseString Returns a string converted to lower case
-(NSString *) uppercaseString Returns a string converted to upper case
-(const char *) UTF8String Returns a string converted to a UTF-8 C-style character string
-(double) doubleValue Returns a string converted to a double
-(float) floatValue Returns a string converted to a floating value
-(NSInteger) integerValue Returns a string converted to an NSInteger integer
-(int) intValue Returns a string converted to an integer












Common NSMutableString Methods
MethodDescription
+(id) stringWithCapacity: size Creates a string initially containing size characters.
-(id) initWithCapacity: size Initializes a string with an initial capacity of size characters.
-(void) setString: nsstring Sets a string to nsstring.
-(void) appendString: nsstring Appends nsstring to the end of the receiver.
-(void) deleteCharactersInRange: range Deletes characters in a specified range.
-(void) insertString: nstring atIndex: i Inserts nsstring into the receiver starting at index i.
-(void) replaceCharactersInRange: range withString: nsstring Replaces characters in a specified range with nsstring.
-(void) replaceOccurrencesOf String: nsstring withString: nsstring2 options: opts range: range Replaces all occurrences of nsstring with nsstring2 within a specified range and according to options opts. Options can include a bitwise-ORed combination of NSBackwardsSearch (the search starts from the end of range), NSAnchoredSearch (nsstring must match from the beginning of the range only), NSLiteralSearch (performs a byte-by-byte comparison), and NSCaseInsensitiveSearch.













Common NSArray Methods
MethodDescription
+(id) arrayWithObjects: obj1, obj2, ... nil Creates a new array with obj1, obj2, ... as its elements
-(BOOL) containsObject: obj Determines whether the array contains obj (uses the isEqual: method)
-(NSUInteger) count Indicates the number of elements in the array
-(NSUInteger) indexOfObject: obj Specifies the index number of the first element that contains obj (uses the isEqual: method)
-(id) objectAtIndex: i Indicates the object stored in element i
-(void) makeObjectsPerform Selector: (SEL) selector Sends the message indicated by selector to every element of the array
-(NSArray *) sortedArrayUsing Selector: (SEL) selector Sorts the array according to the comparison method specified by selector
-(BOOL) writeToFile: path automically: (BOOL) flag Writes the array to the specified file, creating a temporary file first if flag is YES













Common NSMutableArray Methods
MethodDescription
+(id) array Creates an empty array
+(id) arrayWithCapacity: size Creates an array with a specified initial size
-(id) initWithCapacity: size Initializes a newly allocated array with a specified initial size
-(void) addObject: obj Adds obj to the end of the array
-(void) insertObject: obj atIndex: i Inserts obj into element i of the array
-(void) replaceObjectAtIndex: i withObject: obj Replaces element i of the array with obj
-(void) removeObject: obj Removes all occurrences of obj from the array
-(void) removeObjectAtIndex: i Removes element i from the array, moving down elements i+1 through the end of the array
-(void) sortUsingSelector: (SEL) selector Sorts the array based on the comparison method indicated by selector











Common NSDictionary Methods
MethodDescription
+(id) dictionaryWithObjectsAndKeys: obj1, key1, obj2, key2, ..., nil Creates a dictionary with key-object pairs {key1, obj1}, {key2, obj2}, ...
-(id) initWithObjectsAndKeys: obj1, key1, obj2, key2,..., nil Initializes a newly allocated dictionary with key-object pairs {key1, obj1}, {key2, obj2}, ...
-(unsigned int) count Returns the number of entries in the dictionary
-(NSEnumerator *) keyEnumerator Returns an NSEnumerator object for all the keys in the dictionary
-(NSArray *) keysSortedByValueUsingSelector: (SEL) selector Returns an array of keys in the dictionary sorted according to the comparison method selector specifies
-(NSEnumerator *) objectEnumerator Returns an NSEnumerator object for all the values in the dictionary
-(id) objectForKey: key Returns the object for the specified key









Common NSMutableDictionary Methods
MethodDescription
+(id) dictionaryWithCapacity: size Creates a mutable dictionary with an initial specified size
-(id) initWithCapacity: size Initializes a newly allocated dictionary to be of an initial specified size
-(void) removeAllObjects Removes all entries from the dictionary
-(void) removeObjectForKey: key Removes the entry for the specified key from the dictionary
-(void) setObject: obj forKey: key Adds obj to the dictionary for the key key and replaces the value if key already exists













Common NSSet Methods
MethodDescription
+(id) setWithObjects: obj1, obj2, ..., nil Creates a new set from the list of objects
-(id) initWithObjects: obj1, obj2, ..., nil Initializes a newly allocated set with a list of objects
-(NSUInteger) count Returns the number of members in the set
-(BOOL) containsObject: obj Determines whether the set contains obj
-(BOOL) member: obj Determines whether the set contains obj (using the isEqual: method)
-(NSEnumerator *) objectEnumerator Returns an NSEnumerator object for all the objects in the set
-(BOOL) isSubsetOfSet: nsset Determines whether every member of the receiver is present in nsset
-(BOOL) intersectsSet: nsset Determines whether at least one member of the receiver appears in nsset
-(BOOL) isEqualToSet: nsset Determines whether the two sets are equal












Common NSMutableSet Methods
MethodDescription
-(id) setWithCapacity: size Creates a new set with an initial capacity to store size members
-(id) initWithCapacity: size Sets the initial capacity of a newly allocated set to size members
-(void) addObject: obj Adds obj to the set
-(void) removeObject: obj Removes obj from the set
-(void) removeAllObjects Removes all members of the receiver
-(void) unionSet: nsset Adds each member of nsset to the receiver
-(void) minusSet: nsset Removes all members of nsset from the receiver
-(void) intersectSet: nsset Removes all members from the receiver that are not also in nsset















Common NSFileManager Methods
MethodDescription
-(NSData *) contentsAtPath: path Reads data from a file
-(NSData *) createFileAtPath: path contents: (NSData *) data attributes: attr Writes data to a file
-(BOOL) removeFileAtPath: path handler: handler Removes a file
-(BOOL) movePath: from toPath: to handler: handler Renames or moves a file (to cannot already exist)
-(BOOL) copyPath: from toPath: to handler: handler Copies a file (to cannot already exist)
-(BOOL) contentsEqualAtPath: path1 andPath: path2 Compares contents of two files
-(BOOL) fileExistsAtPath: path Tests for file existence
-(BOOL) isReadableFileAtPath: path Tests whether file exists and can be read
-(BOOL) isWritableFileAtPath: path Tests whether file exists and can be written
-(NSDictionary *) fileAttributesAtPath: path traverseLink: (BOOL) flag Gets attributes for file
-(BOOL) changeFileAttributes: attr atPath: path Changes file attributes















Common Path Utility Methods
MethodDescription
+(NSString *) pathWithComponents: components Constructs a valid path from elements in components
-(NSArray *) pathComponents Deconstructs a path into its constituent components
-(NSString *) lastPathComponent Extracts the last component in a path
-(NSString *) pathExtension Extracts the extension from the last component in a path
-(NSString *) stringByAppendingPathComponent: path Adds path to the end of an existing path
-(NSString *) stringByAppendingPathExtension: ext Adds the specified extension to the last component in the path
-(NSString *) stringByDeletingLastPathComponent Removes the last path component
-(NSString *) stringByDeletingPathExtension Removes the extension from the last path component
-(NSString *) stringByExpandingTildeInPath Expands any tildes in the path to the user's home directory (~) or a specified user's home directory (~user)
-(NSString *) stringByResolvingSymlinksInPath Attempts to resolve symbolic links in the path
-(NSString *) stringByStandardizingPath Standardizes a path by attempting to resolve ~, ..(parent directory), .(current directory), and symbolic links



Common Resources Path for iPhone
NSBundle Select all

NSString *myinfoplist = [ [ NSString alloc ] initWithFormat: @"%@/Info.plist", [[NSBundle mainBundle] resourcePath] ];
NSLog (@"Documents Folder is %@",[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]);
NSString *myFile = [ [ NSString alloc ] initWithFormat: @"%@/Documents/file.db", NSHomeDirectory() ];

NSDirectoryEnumerator *dirEnum;
NSString *file;
dirEnum = [ [ NSFileManager defaultManager ] enumeratorAtPath:NSHomeDirectory()];
while (file = [ dirEnum nextObject ]) {
NSLog(@"%@",[NSHomeDirectory() stringByAppendingPathComponent:file]);
/*
Documents/
Library/
Preferences/
MyApp.app/
*/
}






iPhone Sample Source Code : UISlider UITextField UISwitch & UISegmentedControl



This is a sample source code (no interface builder file) implementing the one similar to Setting Bundle for UIKit Controls
UISlider, UITextField, UISwitch & UISegmentedControl

main.m Select all

// main.m
// Settings
//

#import <UIKit/UIKit.h>

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

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


AppDelegate.h Select all

// AppDelegate.h
// Settings
//

#import <UIKit/UIKit.h>
#pragma mark -
#pragma mark MainViewController
#pragma mark -

@interface MainViewController : UITableViewController <UITextFieldDelegate>{

UITextField *activeTextField;
}

- (id) init;
- (void) dealloc;
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

@end

#pragma mark -
#pragma mark AppDelegate
#pragma mark -

@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MainViewController *viewController;
UINavigationController *navigationController;
}

@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) MainViewController *viewController;

@end


AppDelegate.m Select all

// AppDelegate.m
// Settings
//
//

#define DEBUG_BUILD

#ifdef DEBUG_BUILD
#define DEBUGLOG(x) x
#define LogMethod() NSLog(@"%@ %@", self, NSStringFromSelector(_cmd))
#else
#define DEBUGLOG(x)
#define LogMethod()
#endif

#import "AppDelegate.h"

#pragma mark -
#pragma mark MainViewController
#pragma mark -

@implementation MainViewController

- (id) init {
self = [ super initWithStyle: UITableViewStyleGrouped ];

if (self != nil) {
self.title = @"Settings";
}
return self;
}

- (void) loadView {
LogMethod();
[ super loadView ];
}

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
LogMethod();
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)didReceiveMemoryWarning {
LogMethod();
[ super didReceiveMemoryWarning ];
}

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

#pragma mark - UITableView delegates

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch (section) {
case(0):
return 4;
break;
case(1):
return 3;
break;
case(2):
return 1;
break;
}

return 0;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
switch (section) {
case(0):
return @"Game Settings";
break;
case(1):
return @"Advanced Settings";
break;
case(2):
return @"About";
break;
}
return nil;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [ NSString stringWithFormat: @"%d:%d", [ indexPath indexAtPosition: 0 ], [ indexPath indexAtPosition:1 ]];

UITableViewCell *cell = [ tableView dequeueReusableCellWithIdentifier: CellIdentifier];

if (cell == nil) {
cell = [ [ [ UITableViewCell alloc ] initWithFrame: CGRectZero reuseIdentifier: CellIdentifier] autorelease ];

cell.selectionStyle = UITableViewCellSelectionStyleNone;

switch ([ indexPath indexAtPosition: 0]) {
case(0):
switch([ indexPath indexAtPosition: 1]) {
case(0):
{
UISlider *musicVolumeControl = [ [ UISlider alloc ] initWithFrame: CGRectMake(170, 0, 125, 50) ];
musicVolumeControl.minimumValue = 0.0;
musicVolumeControl.maximumValue = 10.0;
musicVolumeControl.tag = 0;
musicVolumeControl.value = 3.5;
musicVolumeControl.continuous = YES;
[musicVolumeControl addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
[ cell addSubview: musicVolumeControl ];
cell.textLabel.text = @"Music Volume"; // OS3
// cell.text = @"Music Volume";
[ musicVolumeControl release ];
}
break;
case(1):
{
UISlider *gameVolumeControl = [ [ UISlider alloc ] initWithFrame: CGRectMake(170, 0, 125, 50) ];
gameVolumeControl.minimumValue = 0.0;
gameVolumeControl.maximumValue = 10.0;
gameVolumeControl.tag = 1;
gameVolumeControl.value = 3.5;
gameVolumeControl.continuous = YES;
[gameVolumeControl addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
[ cell addSubview: gameVolumeControl ];
cell.textLabel.text = @"Game Volume"; // OS3
// cell.text = @"Game Volume";
[ gameVolumeControl release ];
}
break;
case(2):
{
UISegmentedControl *difficultyControl = [ [ UISegmentedControl alloc ] initWithFrame: CGRectMake(170, 5, 125, 35) ];
[ difficultyControl insertSegmentWithTitle: @"Easy" atIndex: 0 animated: NO ];
[ difficultyControl insertSegmentWithTitle: @"Hard" atIndex: 1 animated: NO ];
difficultyControl.selectedSegmentIndex = 0;
difficultyControl.tag = 2;
[difficultyControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
[ cell addSubview: difficultyControl ];
cell.textLabel.text = @"Difficulty"; // OS3
// cell.text = @"Difficulty";
[difficultyControl release];
}
break;
case(3):
{
UISegmentedControl *actionControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects: @"Check", @"Search", @"Tools", nil]];
actionControl.frame = CGRectMake(145, 5, 150, 35);
actionControl.selectedSegmentIndex = 1;
actionControl.tag = 3;
[actionControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
actionControl.segmentedControlStyle = UISegmentedControlStyleBar;

[cell addSubview:actionControl];
cell.textLabel.text = @"Actions"; // OS3
// cell.text = @"Actions";
[actionControl release];
}
break;
}
break;
case(1):
switch ([ indexPath indexAtPosition: 1 ]) {
case(0):
{
UITextField *playerTextField = [ [ UITextField alloc ] initWithFrame: CGRectMake(150, 10, 145, 34) ];
playerTextField.adjustsFontSizeToFitWidth = YES;
playerTextField.textColor = [UIColor blackColor];
playerTextField.font = [UIFont systemFontOfSize:17.0];
playerTextField.placeholder = @"";
playerTextField.backgroundColor = [UIColor clearColor];
playerTextField.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
playerTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; // no auto capitalization support
playerTextField.textAlignment = UITextAlignmentRight;
playerTextField.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard)
playerTextField.returnKeyType = UIReturnKeyDone;
playerTextField.tag = 0;
playerTextField.delegate = self;

playerTextField.clearButtonMode = UITextFieldViewModeNever; // no clear 'x' button to the right
playerTextField.text = @"";
[ playerTextField setEnabled: YES ];
[ cell addSubview: playerTextField ];
cell.textLabel.text = @"Player"; // OS3
// cell.text = @"Player";
[playerTextField release];
}
break;
case(1):
{
UISwitch *resetControl = [ [ UISwitch alloc ] initWithFrame: CGRectMake(200, 10, 0, 0) ];
resetControl.on = YES;
resetControl.tag = 1;
[resetControl addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
[ cell addSubview: resetControl ];
cell.textLabel.text = @"Reset"; // OS3
// cell.text = @"Reset";
[resetControl release];
}
break;
case(2):
{
UISwitch *debugControl = [ [ UISwitch alloc ] initWithFrame: CGRectMake(200, 10, 0, 0) ];
debugControl.on = NO;
debugControl.tag = 2;
[debugControl addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
[ cell addSubview: debugControl ];
cell.textLabel.text = @"Debug"; // OS3
// cell.text = @"Debug";
[debugControl release];
}
break;
}
break;
case(2):
{
UITextField *versionControl = [ [ UITextField alloc ] initWithFrame: CGRectMake(170, 10, 125, 38) ];
versionControl.text = @"1.0.0 Rev. B";
[ cell addSubview: versionControl ];

[ versionControl setEnabled: YES ];
versionControl.tag = 2;
versionControl.delegate = self;
cell.textLabel.text = @"Version"; // OS3
// cell.text = @"Version";
[versionControl release];
}
break;
}
}

return cell;
}

#pragma mark ControlEventTarget Actions


- (void)segmentAction:(UISegmentedControl*)sender
{
if ([activeTextField canResignFirstResponder])
[activeTextField resignFirstResponder];

DEBUGLOG(NSLog(@"segmentAction: sender = %d, segment = %d", [sender tag], [sender selectedSegmentIndex]));
}

- (void)sliderAction:(UISlider*)sender
{
if ([activeTextField canResignFirstResponder])
[activeTextField resignFirstResponder];
DEBUGLOG(NSLog(@"sliderAction: sender = %d, value = %.1f", [sender tag], [sender value]));
}

- (void)switchAction:(UISwitch*)sender
{
if ([activeTextField canResignFirstResponder])
[activeTextField resignFirstResponder];
DEBUGLOG(NSLog(@"switchAction: sender = %d, isOn %d", [sender tag], [sender isOn]));
}


#pragma mark <UITextFieldDelegate> Methods

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
activeTextField = textField;
DEBUGLOG(NSLog(@"textFieldShouldBeginEditing: sender = %d, %@", [textField tag], [textField text]));
return YES;
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
DEBUGLOG(NSLog(@"textFieldDidEndEditing: sender = %d, %@", [textField tag], [textField text]));
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
DEBUGLOG(NSLog(@"textFieldShouldReturn: sender = %d, %@", [textField tag], [textField text]));
activeTextField = nil;
[textField resignFirstResponder];
return YES;
}


@end

#pragma mark -
#pragma mark AppDelegate
#pragma mark -

@implementation AppDelegate

@synthesize window;
@synthesize viewController;

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

// If you want the status bar to be hidden at launch use this:
// application.statusBarHidden = YES;
//
// To set the status bar as black, use the following:
// application.statusBarStyle = UIStatusBarStyleBlackOpaque;


// Create window
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

// this helps in debugging, so that you know "exactly" where your views are placed;
// if you see "red", you are looking at the bare window, otherwise use black
// window.backgroundColor = [UIColor redColor];

viewController = [ [ MainViewController alloc ] init ];

navigationController = [ [ UINavigationController alloc ] initWithRootViewController: viewController ];

/* Anchor the view to the window */
[window addSubview:[navigationController view]];

/* Make the window key and visible */
[window makeKeyAndVisible];
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
// low on memory: do whatever you can to reduce your memory foot print here
}


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

@end




Wednesday, January 21, 2009

Source Code : Get Hardware Info of iPhone

This is a collection of open source codes to print out the hardware info of iPhone. If you know more, please post link here in comment and I will update it.

Battery Info source (requires IOKit header files from SimulatorSDK)
http://forums.macrumors.com/showthread.php?t=474628

Memory & CPU
http://furbo.org/2007/08/21/what-the-iphone-specs-dont-tell-you/

Process
Landon Fuller, iphonesdk@googlegroups.com

hwinfo.c Select all

#import <stdio.h>
#import <string.h>

#import <mach/mach_host.h>
#import <sys/sysctl.h>

#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/ps/IOPowerSources.h>
#include <IOKit/ps/IOPSKeys.h>

#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>

void printMemoryInfo()
{
size_t length;
int mib[6];
int result;

printf("Memory Info\n");
printf("-----------\n");

int pagesize;
mib[0] = CTL_HW;
mib[1] = HW_PAGESIZE;
length = sizeof(pagesize);
if (sysctl(mib, 2, &pagesize, &length, NULL, 0) < 0)
{
perror("getting page size");
}
printf("Page size = %d bytes\n", pagesize);
printf("\n");

mach_msg_type_number_t count = HOST_VM_INFO_COUNT;

vm_statistics_data_t vmstat;
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, &count) != KERN_SUCCESS)
{
printf("Failed to get VM statistics.");
}

double total = vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count;
double wired = vmstat.wire_count / total;
double active = vmstat.active_count / total;
double inactive = vmstat.inactive_count / total;
double free = vmstat.free_count / total;

printf("Total = %8d pages\n", vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count);
printf("\n");
printf("Wired = %8d bytes\n", vmstat.wire_count * pagesize);
printf("Active = %8d bytes\n", vmstat.active_count * pagesize);
printf("Inactive = %8d bytes\n", vmstat.inactive_count * pagesize);
printf("Free = %8d bytes\n", vmstat.free_count * pagesize);
printf("\n");
printf("Total = %8d bytes\n", (vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count) * pagesize);
printf("\n");
printf("Wired = %0.2f %%\n", wired * 100.0);
printf("Active = %0.2f %%\n", active * 100.0);
printf("Inactive = %0.2f %%\n", inactive * 100.0);
printf("Free = %0.2f %%\n", free * 100.0);
printf("\n");

mib[0] = CTL_HW;
mib[1] = HW_PHYSMEM;
length = sizeof(result);
if (sysctl(mib, 2, &result, &length, NULL, 0) < 0)
{
perror("getting physical memory");
}
printf("Physical memory = %8d bytes\n", result);
mib[0] = CTL_HW;
mib[1] = HW_USERMEM;
length = sizeof(result);
if (sysctl(mib, 2, &result, &length, NULL, 0) < 0)
{
perror("getting user memory");
}
printf("User memory = %8d bytes\n", result);
printf("\n");
}

void printProcessorInfo()
{
size_t length;
int mib[6];
int result;

printf("Processor Info\n");
printf("--------------\n");

mib[0] = CTL_HW;
mib[1] = HW_CPU_FREQ;
length = sizeof(result);
if (sysctl(mib, 2, &result, &length, NULL, 0) < 0)
{
perror("getting cpu frequency");
}
printf("CPU Frequency = %d hz\n", result);

mib[0] = CTL_HW;
mib[1] = HW_BUS_FREQ;
length = sizeof(result);
if (sysctl(mib, 2, &result, &length, NULL, 0) < 0)
{
perror("getting bus frequency");
}
printf("Bus Frequency = %d hz\n", result);
printf("\n");
}

int printBatteryInfo()
{
CFTypeRef blob = IOPSCopyPowerSourcesInfo();
CFArrayRef sources = IOPSCopyPowerSourcesList(blob);

CFDictionaryRef pSource = NULL;
const void *psValue;

int numOfSources = CFArrayGetCount(sources);
if (numOfSources == 0) {
perror("Error getting battery info");
return 1;
}

printf("Battery Info\n");
printf("------------\n");

for (int i = 0 ; i < numOfSources ; i++)
{
pSource = IOPSGetPowerSourceDescription(blob, CFArrayGetValueAtIndex(sources, i));
if (!pSource) {
perror("Error getting battery info");
return 2;
}
psValue = (CFStringRef)CFDictionaryGetValue(pSource, CFSTR(kIOPSNameKey));

int curCapacity = 0;
int maxCapacity = 0;
int percent;

psValue = CFDictionaryGetValue(pSource, CFSTR(kIOPSCurrentCapacityKey));
CFNumberGetValue((CFNumberRef)psValue, kCFNumberSInt32Type, &curCapacity);

psValue = CFDictionaryGetValue(pSource, CFSTR(kIOPSMaxCapacityKey));
CFNumberGetValue((CFNumberRef)psValue, kCFNumberSInt32Type, &maxCapacity);

percent = (int)((double)curCapacity/(double)maxCapacity * 100);

printf ("powerSource %d of %d: percent: %d/%d = %d%%\n", i+1, CFArrayGetCount(sources), curCapacity, maxCapacity, percent);
printf("\n");

}

}

int printProcessInfo() {
int mib[5];
struct kinfo_proc *procs = NULL, *newprocs;
int i, st, nprocs;
size_t miblen, size;

/* Set up sysctl MIB */
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_ALL;
mib[3] = 0;
miblen = 4;

/* Get initial sizing */
st = sysctl(mib, miblen, NULL, &size, NULL, 0);

/* Repeat until we get them all ... */
do {
/* Room to grow */
size += size / 10;
newprocs = realloc(procs, size);
if (!newprocs) {
if (procs) {
free(procs);
}
perror("Error: realloc failed.");
return (0);
}
procs = newprocs;
st = sysctl(mib, miblen, procs, &size, NULL, 0);
} while (st == -1 && errno == ENOMEM);

if (st != 0) {
perror("Error: sysctl(KERN_PROC) failed.");
return (0);
}

/* Do we match the kernel? */
assert(size % sizeof(struct kinfo_proc) == 0);

nprocs = size / sizeof(struct kinfo_proc);

if (!nprocs) {
perror("Error: printProcessInfo.");
return(0);
}
printf(" PID\tName\n");
printf("-----\t--------------\n");
for (i = nprocs-1; i >=0; i--) {
printf("%5d\t%s\n",(int)procs[i].kp_proc.p_pid, procs[i].kp_proc.p_comm);
}
free(procs);
return (0);
}


int main(int argc, char **argv)
{
printf("iPhone Hardware Info\n");
printf("====================\n");
printf("\n");

printMemoryInfo();
printProcessorInfo();
printBatteryInfo();
printProcessInfo();
return (0);
}


MAC Address & IP address of network interfaces
original source from devforums.apple.com and modified to show IP address and exclude loopback addresses

macaddress.c Select all

#include <stdio.h>
#include <stdlib.h>
#include <ifaddrs.h>
#include <string.h>
#include <stdbool.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <arpa/inet.h>
#include <ifaddrs.h>

#if ! defined(IFT_ETHER)
#define IFT_ETHER 0x6/* Ethernet CSMACD */
#endif

int main(int argc, char **argv)
{
bool success;
struct ifaddrs *addrs;
const struct ifaddrs *cursor;
const struct sockaddr_dl *dlAddr;
const uint8_t *base;
int i;

success = getifaddrs(&addrs) == 0;
if (success) {
cursor = addrs;
while (cursor != NULL) {
if ((cursor->ifa_flags & IFF_LOOPBACK) == 0 ) {
printf("%s ", (char *)cursor->ifa_name);
printf("%s\n",inet_ntoa(((struct sockaddr_in *)cursor->ifa_addr)->sin_addr));
}
if ( (cursor->ifa_addr->sa_family == AF_LINK)
&& (((const struct sockaddr_dl *) cursor->ifa_addr)->sdl_type ==IFT_ETHER)
) {
dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr;
// fprintf(stderr, " sdl_nlen = %d\n", dlAddr->sdl_nlen);
// fprintf(stderr, " sdl_alen = %d\n", dlAddr->sdl_alen);
base = (const uint8_t *) &dlAddr->sdl_data[dlAddr->sdl_nlen];
printf(" MAC address ");
for (i = 0; i < dlAddr->sdl_alen; i++) {
if (i != 0) {
printf(":");
}
printf("%02x", base[i]);
}
printf("\n");
}
cursor = cursor->ifa_next;
}
}
return 0;
}

 
 
 
There are also iPhone device info from the SDK in UIDevice.h
UIDevice.h Select all

+ (UIDevice *)currentDevice;
@property(nonatomic,readonly,retain) NSString *name; // e.g. "My iPhone"
@property(nonatomic,readonly,retain) NSString *model; // e.g. @"iPhone", @"iPod Touch"
@property(nonatomic,readonly,retain) NSString *localizedModel; // localized version of model
@property(nonatomic,readonly,retain) NSString *systemName; // e.g. @"iPhone OS"
@property(nonatomic,readonly,retain) NSString *systemVersion; // e.g. @"2.0"
@property(nonatomic,readonly) UIDeviceOrientation orientation; // return current device orientation
@property(nonatomic,readonly,retain) NSString *uniqueIdentifier; // a string unique to each device based on various hardware info.

undocumented
- (id)buildVersion;
- (int)batteryState;





 
 
 

Monday, January 12, 2009

How-to do ARM GCC Inline Assembler for iPhone

The following code demonstrates an example to write Inline Assembler in llvm-gcc for iPhone ARM

arithmetic_shift_right.c Select all

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
int i = atoi(argv[1]);
asm volatile ("mov %0, %1, ASR #1" : "=r"(i) : "r"(i));
printf("arithmetic_shift_right is %d\n", i);
exit(0);
}


The general format (ref) is
asm volatile (assembler instructions : output operands (optional) : input operands (optional) : clobbered registers (optional) );

e.g.
asm volatile ("mul %0, %1, %2" : "=r" (result) : "r" (number1) , "r" (number2));


This version is for Assembler Macro

arithmetic_shift_right.c Select all

#include <stdio.h>
#include <stdlib.h>

inline int arithmetic_shift_right(int a) {
int y;
__asm__("mov %0, %1, ASR #1" : "=r" (y) : "r" (a));
// Register R0 will become the value of register R1 shifted to the right by 1 bit, with the sign maintained.
return y;
}

int main(int argc, char *argv[]) {
int i = atoi(argv[1]);
printf("arithmetic_shift_right %d is %d\n", i, arithmetic_shift_right(i));
exit(0);
}



Below is the otool output for Assembler Macro
otool -tV Select all

_arithmetic_shift_right:
00001eb4 e92d4080 stmdb sp!, {r7, lr}
00001eb8 e28d7000 add r7, sp, #0 ; 0x0
00001ebc e24dd008 sub sp, sp, #8 ; 0x8
00001ec0 e58d0000 str r0, [sp]
00001ec4 e59d3000 ldr r3, [sp]
00001ec8 e1a030c3 mov r3, r3, asr #1       @@ arithmetic shift right
00001ecc e58d3004 str r3, [sp, #4]
00001ed0 e59d3004 ldr r3, [sp, #4]
00001ed4 e1a00003 mov r0, r3
00001ed8 e247d000 sub sp, r7, #0 ; 0x0
00001edc e8bd8080 ldmia sp!, {r7, pc}


Below is the otool output for Assembler Macro (after full optimzation -O2)
otool -tV Select all

_arithmetic_shift_right:
00001f04 e1a000c0 mov r0, r0, asr #1
00001f08 e12fff1e bx lr




Assembler Macro for more than one assembler instruction
arithmetic shift right then perform 16 bit binary multiplication

Assembler Macros Select all

__asm__("mov %0, %1, ASR #1\n\t"
"mul %0, %0, %1"
: "=r" (y) : "r" (a));





Wednesday, January 7, 2009

Enable Emoji without jailbreak iPhone

There is no need to guess and wait for update. This patch works for firmware 2.2 / 2.2.1

Emoji is the Japanese name for pictorial characters, smileys and emoticons. The characters are similar to the commonly used emoticons but Emoji contains over 461 icons. These icons are standardized and built into most japanese handsets.



Currently, this new feature for firmware 2.2 is available to Japanese iPhone 3G or jailbreak iPhone with emoji patch only.

To enable Emoji without jailbreak, you need to install an app that I made.

This is not a vcard.vcf method, this is a patch like the one in Cydia but available to iPhone and no jailbreak required. The above screen dump is directly captured from my iPhone 3G, and no jailbreak.


Touch Dial Emoji Version 1.2

To enable Emoji, follow these steps
(1) Upgrade iPhone firmware to 2.2

(2) Install Touch Dial Emoji version 1.2 from App Store
iTunes Link http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=286534260&mt=8

Yes, you have to pay for this app. If you don't like to pay, jailbreak your iPhone and install the package from Cydia, it is free.

(3) Goto Settings -> Touch Dial -> turn Enable Smiley icon to ON


(4) Launch Touch Dial

(5) Go to Settings>General>Keyboard>International Keyboards>Japanese and enable "Emoji."




The difficulty of this app is not on coding as the method is well known, it is about how to get it past.

One more thing, new hack is coming.

CodeSign error: a valid provisioning profile is required

"CodeSign error: a valid provisioning profile is required for product type 'Application' in SDK 'Device - iPhone OS 2.2"

This error will appear when you update your provisioning profile in iPhone SDK 2.2
or after the expiration of developer certificate and that you have a new provisioning profile from the developer portal

This is the solution (which is modified from http://www.furmanek.net/54/iphone-sdk-22-codesign-error/)

Suppose you have copied your provisioning profile called "iPhone_Development.mobileprovision" to the Library folder and build & go an old iPhone project called "MyApp", and this annoying error appears

(1) cd ~/Library/MobileDevice/Provisioning\ Profiles/

(2) find out the UUID of the provisioning profile
strings iPhone_Development.mobileprovision | grep "<string>.*-.*</string>"

output is like this
<string>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>

(3) copy that UUID between the string tag

(4) close xcode and go to your project
cd ~/Projects/MyApp/MyApp.xcodeproj

(5) Use a text editor to open the project.pbxproj
find the string PROVISIONING_PROFILE

paste the UUID that you copied from step (3) and put it in both Debug and Release Sections (do multiple finds) for the following line
e.g.
PROVISIONING_PROFILE = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

(6) Launch XCode and open the project and build & go again


Updates :
Deleting all of the lines "PROVISIONING_PROFILE" in project.pbxproj will also fix the problem for iPhone SDK 3 or above





Sunday, January 4, 2009

UICatalog : Makefile for Apple sample iPhone SDK code

To check out UICatalog from Apple developer website or from here
svn co -r16 http://apiexplorer.googlecode.com/svn/trunk/UICatalog UICatalog

The modification here is to show how to change the xib file to iphone code (as in revision 17) here
http://code.google.com/p/apiexplorer/source/detail?r=17

Furthermore, if you checkout the revision 18, you can have the ldid binary and Makefiles for installation to iPhone /Applications folder
Mac : (using Makefile.mac and ldid_mac)
Linux toolchain : (using Makefile.linux and ldid_linux)
iPhone gcc : (using Makefile.iphone and please install ldid package in Cydia)

Instructions to compile using Makefile for UICatalog under Mac
(1) Checkout revision 18
svn co -r18 http://apiexplorer.googlecode.com/svn/trunk/UICatalog UICatalog

(2) Install respring in iPhone (if haven't done so) assume your iphone ip is 10.0.2.2
make install_respring -f Makefile.mac IPHONE_IP=10.0.2.2

(3) modify the IPHONE_IP (to the actual IP address of iPhone) in Makefile.mac
IPHONE_IP=10.0.2.2

(4) make & install
make -f Makefile.mac
make install -f Makefile.mac


If you want to install your Mac / Linux public key in iPhone so as to avoid typing password using ssh, please refer to my previous post here

Instructions to compile using Makefile for UICatalog under Linux toolchain

Please refer to these two articles in how to install toolchain in Linux
http://iphonesdkdev.blogspot.com/2008/11/upgrade-vmware-image-to-ubuntu-810-for.html
http://iphonesdkdev.blogspot.com/2008/10/how-to-install-llvm-gcc-for-iphone-sdk.html

(1) Checkout revision 18
svn co -r18 http://apiexplorer.googlecode.com/svn/trunk/UICatalog UICatalog

(2) Install respring in iPhone (if haven't done so) assume your iphone ip is 10.0.2.2
make install_respring -f Makefile.linux IPHONE_IP=10.0.2.2

(3) modify the IPHONE_IP (to the actual IP address of iPhone) and toolchain (to the toolchain folder location) in Makefile.linux
IPHONE_IP=10.0.2.2
toolchain=/usr/toolchain2


(4) make & install
make -f Makefile.linux
make install -f Makefile.linux


If you want to install your Mac / Linux public key in iPhone so as to avoid typing password using ssh, please refer to my previous post here

Instructions to compile using Makefile for UICatalog under iPhone gcc
Assume already install iphone gcc, ldid, make and subversion packages in Cydia and also have sdk headers / lib files

(1) Checkout revision 18
svn co -r18 http://apiexplorer.googlecode.com/svn/trunk/UICatalog UICatalog

(2) Install respring in iPhone (if haven't done so)
make install_respring -f Makefile.iphone

(3) modify the SDK (to the sdk headers and lib files location) in Makefile.iphone
SDK = /var/toolchain2/sys20

(4) make & install
make -f Makefile.iphone
make install -f Makefile.iphone


P.S. There is a great tool here to convert .xib / *.nib to .m
see here
http://github.com/akosma/nib2objc/tree/master


If you need to compile ldid in Intel machine, here is how

wget http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.476.tgz
tar -zxf ldid-1.0.476.tgz
cd ldid-1.0.476
g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c
sudo cp -a util/ldid /usr/bin


For PowerPC, you need the patch file here
http://fink.cvs.sourceforge.net/viewvc/*checkout*/fink/dists/10.4/unstable/crypto/finkinfo/ldid.patch?revision=1.1

and to apply the patch before compilation, use this

curl -O http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.476.tgz
tar -zxf ldid-1.0.476.tgz
wget -qO- http://fink.cvs.sourceforge.net/viewvc/*checkout*/fink/dists/10.4/unstable/crypto/finkinfo/ldid.patch?revision=1.1 | patch -p0
cd ldid-1.0.476
g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c
sudo cp -a util/ldid /usr/bin


Updates : The source of of ldid is moved to here
wget http://www.telesphoreo.org/export/477/trunk/data/ldid/ldid-1.0.476.tgz
or updated one here
wget http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.610.tgz

Updates : If you compiled it in cgywin, you need to add (uint32_t) in the source code ldid.cpp that has ambiguous overload call error message like this

error: call of overloaded 'Swap(int)' is ambiguous






Friday, January 2, 2009

How-to create svn server (subversion) in iPhone

This guide shows you how to setup svn+ssh server in pwned iPhone

(1) Install subversion package in Cydia
apt-get install subversion

(2) create repository in iPhone (e.g. with the Project called UICatalog)

mkdir -p /var/root/Library/Subversion/Repository
svnadmin create /var/root/Library/Subversion/Repository/UICatalog
mkdir -p /tmp/UICatalog/trunk /tmp/UICatalog/branches /tmp/UICatalog/tags
svn import /tmp/UICatalog/ file:///var/root/Library/Subversion/Repository/UICatalog -m "Create Directory Structure"
rm -rf /tmp/UICatalog


(3) Import Project directory
import from iPhone
svn import UICatalog file:///var/root/Library/Subversion/Repository/UICatalog/trunk -m "Import project dir from iPhone"

import from Mac (assume iPhone IP is 10.0.2.2)
svn import UICatalog svn+ssh://root@10.0.2.2/var/root/Library/Subversion/Repository/UICatalog/trunk -m "Import project dir from Mac"

(4) Checkout Project directory
checkout to Mac (assume iPhone IP is 10.0.2.2)
svn checkout svn+ssh://root@10.0.2.2/var/root/Library/Subversion/Repository/UICatalog/trunk UICatalog

checkout a specific revision 5 to Mac (assume iPhone IP is 10.0.2.2)
svn co -r 5 svn+ssh://root@10.0.2.2/var/root/Library/Subversion/Repository/UICatalog/trunk UICatalogR2

checkout to iPhone to another dir
svn checkout file:///var/root/Library/Subversion/Repository/UICatalog/trunk UICatalog2

checkout a specific revision 5 to iPhone
svn co -r 5 file:///var/root/Library/Subversion/Repository/UICatalog/trunk UICatalog_v5


(5)Other useful svn commands
(change directory to the working copy that was checkout in iPhone)
cd UICatalog2
svn info
svn commit -m 'commit changes'
svn ls file:///var/root/Library/Subversion/Repository/UICatalog/trunk
svn log


(change directory to the working copy that was checkout in Mac)
cd UICatalog
svn add newfile.m
svn info
svn commit -m 'commit changes'
svn ls svn+ssh://root@10.0.2.2/var/root/Library/Subversion/Repository/UICatalog/trunk
svn log


(6) svn to googlecode.com
svn checkout https://<yourproject>.googlecode.com/svn/trunk/<yourprojectdirname> --username <your username without @gmail.com>

When prompted, enter your generated googlecode.com password.
The googlecode.com svn password is in the googlecode.com (it is not the same as the gmail password)

Profile -> Settings

cd <yourprojectdirname>
svn add newfile.m
svn commit -m 'commit changes: adding newfile.m'


import to a subdirectory
svn import <yourprojectdirname> https://<yourproject>.googlecode.com/svn/trunk/<yourprojectdirname>/ --username <your username without @gmail.com> -m 'commit changes: importing'

delete directory/files that were in the wrong place
svn delete -m "Deleting wrong place commit" https://<yourproject>.googlecode.com/svn/trunk/<directorytobedeleted> https://<yourproject>.googlecode.com/svn/trunk/<filetobedeleted> ....

(7) Others
The use of Xcode 3 and subversion is in Apple documentation here
http://developer.apple.com/mac/articles/server/subversionwithxcode3.html

You can make use of this to manage SCM for XCode project to google code, Mac or iPhone


(8) GIT
If you need git on leopard, here
http://code.google.com/p/git-osx-installer/
or use MacPorts (port install git-core)

or you can compile and install from source

mkdir ~/src
cd ~/src/
curl -O http://kernel.org/pub/software/scm/git/git-1.6.5.3.tar.bz2
tar -xjvf git-1.6.5.3.tar.bz2
cd git-1.6.5.3
./configure --prefix=/usr/local
make
sudo make install
git --version





Thursday, January 1, 2009

XCode Template for cocos2d

This open source game Libray is for you to development games for iPhone using XCode. The current version is 0.6.2

The project source is here
http://code.google.com/p/cocos2d-iphone/

These are the features of the library:
* Scene management (workflow)
* Transitions between scenes
* Sprites
* Actions
* Basic menus and buttons
* Integrated Chipmunk 2d physics engine
* Particle system
* Text rendering support
* Texture Atlas support
* Tile Map support
* Parallax scrolling
* Touch/Accelerometer support
* Portrait and Landscape mode
* Integrated Pause/Resume
* Supports PowerVR Texture Compression (PVRTC) format
* Language: objective-c
* Open Source: Compatible with open and closed source projects
* OpenGL ES 1.1 based

Here is the XCode Template, so that you can create new project and start 2d game programming

Installation Instruction of this XCode Template for cocos2d 0.62

curl -O http://apiexplorer.googlecode.com/files/cocos2d.zip
unzip cocos2d.zip -d "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates"


Here is a quick primer guide to start development with a simple game using cocos2d, this XCode template is also created based on the method as described in this article
http://monoclestudios.com/cocos2d_whitepaper.html
and these two as well
http://lethain.com/entry/2008/oct/03/notes-on-cocos2d-iphone-development/
http://lethain.com/entry/2008/oct/20/touch-detection-in-cocos2d-iphone/

After installation of this XCode Template, you can create new project for cocos2d library

A Makefile is also included so that you can build the created new project and ldid fake codeign and install in the /Application folder of iPhone

(1) you need to change the IPHONE_IP in the Makefile
(2) make install_respring
(3) make
(4) make install

If you want to install your Mac public key in iPhone so as to avoid typing password using ssh, please refer to my previous post here

The api documentation of cocos2d are here
http://groups.google.com/group/cocos2d-iphone-discuss

Update : Cocos2d v0.7 XCode Template

curl -O http://apiexplorer.googlecode.com/files/cocos2d_v0.7.zip
unzip cocos2d_v0.7.zip -d "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates"


This new XCode Template v0.7 has been restructured so that when cocos2d is updated in the future, you can just copy the new cocos2d directory and replace the cocos2d-iphone in the old project directory e.g.


cp -r ~/Downloads/cocos2d-iphone-0.8/* ~/Projects/myproject/cocos2d-iphone/
rm -fr ~/Projects/myproject/cocos2d-iphone/cocos2d-iphone.xcodeproj