Friday, September 19, 2008

Xcode Template for pwned iPhone device updated to version 3.5.2

This Xcode Template is now updated to version 3.5.2

To install, run these in Mac Terminal (assume you have installed the Xcode in /Developer folder)


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

MD5 (ToolChainTemplate_v352.zip) = 5de15c4cc9f7bab7feeafff5f121da36



There are 4 new project templates to build the command line utility for iPhone
C++ Tool (.cpp)
CoreFoundation Tool (.c)
Foundation Tool (.m)
Objective C++ Tool (.mm)


These 4 command line utility templates used wifi connection to install compiled binary in your iPhone, so you need not connect your iPhone via usb port and MobileInstallation patch is not needed.

Requirements & Info:
(1) Default use Open toolchain headers
(2) iPhone and Mac connected to wifi (you should change the IPHONE_IP in Project Settings)
(3) Open SSH and Link Indenty Editor installed in iPhone
(4) Mac's ssh key installed in iPhone
(5) Debug / Release build to iPhone folder /private/var/root (no Build & Go) and you should change IPHONE_INSTALL_DIR in the Project Settings
(6) Cannot build to Simulator

Xcode Template Version 3.5.2 adds a Static Library Template for iPhone
To build the Universary Library for i386 and arm
First build it on "Device" "Release"
Second build it on "Simulator" "Release"
Then the Universary Library binary will be in the project directory
To examine the content of the Universary Library binary, run ./otoolprint.sh in the project folder


Open Tool Chain Application
This template uses open toolchain headers provides a starting point for any application without Interface Builder.

Requirements and Info:
(1) No Interface Builder
(2) Default use open toolchain headers
(3) For pwned iPhone / iPod Touch with patched MobileInstallation
(4) codesign certificate "iPhone Pwned Developer" installed in Mac
(5) XCode SDK Info.plist Setting has removed Provisioning Profile requirement
(6) Cannot build to Simulator


View-Based Application
This template provides a starting point for an application that uses a single view. It provides a view controller to manage the view, and a nib file that contains the view.

Requirements and Info:
(1) Default use official iPhone SDK headers
(2) For pwned iPhone / iPod Touch with patched MobileInstallation
(3) codesign certificate "iPhone Pwned Developer" installed in Mac
(4) XCode SDK Info.plist Setting has removed Provisioning Profile requirement

Window-Based Application
This template provides a starting point for any application without Interface Builder and provides a minimal iPhone application with a single view, ready for customizing.
This is a good starting point for your first application. In the UIView subclass, you can implement methods to draw content on the screen and to respond to touches. In a more full-featured application, you typically add a view controller to handle data and to manage rotation.

Requirements and Info:
(1) No Interface Builder
(2) Default use official iPhone SDK headers
(3) For pwned iPhone / iPod Touch with patched MobileInstallation
(4) codesign certificate "iPhone Pwned Developer" installed in Mac
(5) XCode SDK Info.plist Setting has removed Provisioning Profile requirement

Updated Notes
If you have "security policy error" after Build & Go. Do these steps

(1) Install a new free app from App Store in iPhone (not sync from iTunes)
(2) Launch that newly purchased free app and then close it.
(3) Reboot your iPhone (that is power off and on again)
(4) Launch the app again that you have Build & Go in Xcode to iPhone.

Thursday, September 18, 2008

[Firmware 2.1] How to skip provisioning profile for iPhone SDK

How to skip provisioning profile for iPhone SDK (build 9M2517) for firmware 2.1

First close your Xcode and backup the iPhoneOS.platform Info.plist by running this in Mac Terminal


sudo cp -p /Developer/Platforms/iPhoneOS.platform/Info.plist /Developer/Platforms/iPhoneOS.platform/Info.plist.bak


Then edit the iPhoneOS.platform Info.plist file

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


and change

<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>YES</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>YES</string>


to this


<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>


Launch Xcode and then create new project using my Xcode Template for pwned device "View-Based Application" to build and go to either Project Settings 2.0 or Project Settings 2.1 or iPhone Simulator and you don't need the trick to reset it anymore.

Remember, you still need a fake codesign identity and patched MobileInstallation binary in your iPhone.

If you are registered iPhone Developer with provisioning profile and codesign cert from Apple, please remember to revert the PhoneOS.platform Info.plist back to the original one before building your project to App Store.

Updated Notes
If you have "security policy error" after Build & Go. Do these steps

(1) Install a new free app from App Store in iPhone (not sync from iTunes)
(2) Launch that newly purchased free app and then close it.
(3) Reboot your iPhone (that is power off and on again)
(4) Launch the app again that you have Build & Go in Xcode to iPhone.

Please also refer to the latest article for SDK2.2.1
http://iphonesdkdev.blogspot.com/2009/01/how-to-skip-provisioning-profile-for.html




Sunday, September 14, 2008

Copy iPhone SDK headers from Mac to iPhone

Use this shell script in Mac Terminal to copy the installed SDK header files (firmware 2.1) to iPhone , if you have installed the iPhone SDK (build 9M2517) for (2.0 & 2.1 development)
directly and you have to change IPHONEIP for your actual iPhone IP address

copySDKHeaders2.sh : Select all

#!/bin/sh
IPHONEIP=10.0.2.2
#SDKVER=2.0
#SDKVER=2.1
SDKVER=2.2
sdkroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk/System/Library/Frameworks
sdkframeworks[1]=$sdkroot/AddressBook.framework/Headers/*
sdkframeworks[2]=$sdkroot/AddressBookUI.framework/Headers/*
sdkframeworks[3]=$sdkroot/AudioToolbox.framework/Headers/*
sdkframeworks[4]=$sdkroot/AudioUnit.framework/Headers/*
sdkframeworks[5]=$sdkroot/CFNetwork.framework/Headers/*
sdkframeworks[6]=$sdkroot/CoreAudio.framework/Headers/*
sdkframeworks[7]=$sdkroot/CoreFoundation.framework/Headers/*
sdkframeworks[8]=$sdkroot/CoreGraphics.framework/Headers/*
sdkframeworks[9]=$sdkroot/CoreLocation.framework/Headers/*
sdkframeworks[10]=$sdkroot/Foundation.framework/Headers/*
sdkframeworks[11]=$sdkroot/MediaPlayer.framework/Headers/*
sdkframeworks[12]=$sdkroot/OpenAL.framework/Headers/*
sdkframeworks[13]=$sdkroot/OpenGLES.framework/Headers/*
sdkframeworks[14]=$sdkroot/QuartzCore.framework/Headers/*
sdkframeworks[15]=$sdkroot/Security.framework/Headers/*
sdkframeworks[16]=$sdkroot/SystemConfiguration.framework/Headers/*
sdkframeworks[17]=$sdkroot/UIKit.framework/Headers/*
sdkframeworks[18]=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVER}.sdk/System/Library/Frameworks/IOKit.framework/Headers/*
iphonesdkroot=/var/sdk
iphoneframeworksroot=$iphonesdkroot/include
iphoneframeworks[1]=$iphoneframeworksroot/AddressBook/
iphoneframeworks[2]=$iphoneframeworksroot/AddressBookUI/
iphoneframeworks[3]=$iphoneframeworksroot/AudioToolbox/
iphoneframeworks[4]=$iphoneframeworksroot/AudioUnit/
iphoneframeworks[5]=$iphoneframeworksroot/CFNetwork/
iphoneframeworks[6]=$iphoneframeworksroot/CoreAudio/
iphoneframeworks[7]=$iphoneframeworksroot/CoreFoundation/
iphoneframeworks[8]=$iphoneframeworksroot/CoreGraphics/
iphoneframeworks[9]=$iphoneframeworksroot/CoreLocation/
iphoneframeworks[10]=$iphoneframeworksroot/Foundation/
iphoneframeworks[11]=$iphoneframeworksroot/MediaPlayer/
iphoneframeworks[12]=$iphoneframeworksroot/OpenAL/
iphoneframeworks[13]=$iphoneframeworksroot/OpenGLES/
iphoneframeworks[14]=$iphoneframeworksroot/QuartzCore/
iphoneframeworks[15]=$iphoneframeworksroot/Security/
iphoneframeworks[16]=$iphoneframeworksroot/SystemConfiguration/
iphoneframeworks[17]=$iphoneframeworksroot/UIKit/
iphoneframeworks[18]=$iphoneframeworksroot/IOKit/

ssh root@$IPHONEIP "mkdir -p $iphoneframeworksroot"
scp -r /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk/usr/include root@$IPHONEIP:$iphonesdkroot
scp -r /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk/usr/lib root@$IPHONEIP:$iphonesdkroot

for index in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
do
echo "copying ${sdkframeworks[index]} to ${iphoneframeworks[index]}"
ssh root@$IPHONEIP "mkdir -p ${iphoneframeworks[index]}"
scp -r ${sdkframeworks[index]} root@$IPHONEIP:${iphoneframeworks[index]}
done


This is for SDK 3.0 header files to iPhone

copySDKHeaders3.sh : Select all

#!/bin/sh
IPHONEIP=10.0.2.2
SDKVER=3.0
sdkroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk/System/Library/Frameworks
sdkframeworks[1]=$sdkroot/AVFoundation.framework/Headers/*
sdkframeworks[2]=$sdkroot/AddressBook.framework/Headers/*
sdkframeworks[3]=$sdkroot/AddressBookUI.framework/Headers/*
sdkframeworks[4]=$sdkroot/AudioToolbox.framework/Headers/*
sdkframeworks[5]=$sdkroot/AudioUnit.framework/Headers/*
sdkframeworks[6]=$sdkroot/CFNetwork.framework/Headers/*
sdkframeworks[7]=$sdkroot/CoreAudio.framework/Headers/*
sdkframeworks[8]=$sdkroot/CoreData.framework/Headers/*
sdkframeworks[9]=$sdkroot/CoreFoundation.framework/Headers/*
sdkframeworks[10]=$sdkroot/CoreGraphics.framework/Headers/*
sdkframeworks[11]=$sdkroot/CoreLocation.framework/Headers/*
sdkframeworks[12]=$sdkroot/ExternalAccessory.framework/Headers/*
sdkframeworks[13]=$sdkroot/Foundation.framework/Headers/*
sdkframeworks[14]=$sdkroot/GameKit.framework/Headers/*
sdkframeworks[15]=$sdkroot/MapKit.framework/Headers/*
sdkframeworks[16]=$sdkroot/MediaPlayer.framework/Headers/*
sdkframeworks[17]=$sdkroot/MessageUI.framework/Headers/*
sdkframeworks[18]=$sdkroot/MobileCoreServices.framework/Headers/*
sdkframeworks[19]=$sdkroot/OpenAL.framework/Headers/*
sdkframeworks[20]=$sdkroot/OpenGLES.framework/Headers/*
sdkframeworks[21]=$sdkroot/QuartzCore.framework/Headers/*
sdkframeworks[22]=$sdkroot/Security.framework/Headers/*
sdkframeworks[23]=$sdkroot/StoreKit.framework/Headers/*
sdkframeworks[24]=$sdkroot/SystemConfiguration.framework/Headers/*
sdkframeworks[25]=$sdkroot/UIKit.framework/Headers/*
sdkframeworks[26]=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVER}.sdk/System/Library/Frameworks/IOKit.framework/Headers/*
iphonesdkroot=/var/sdk
iphoneframeworksroot=$iphonesdkroot/include
iphoneframeworks[1]=$iphoneframeworksroot/AVFoundation/
iphoneframeworks[2]=$iphoneframeworksroot/AddressBook/
iphoneframeworks[3]=$iphoneframeworksroot/AddressBookUI/
iphoneframeworks[4]=$iphoneframeworksroot/AudioToolbox/
iphoneframeworks[5]=$iphoneframeworksroot/AudioUnit/
iphoneframeworks[6]=$iphoneframeworksroot/CFNetwork/
iphoneframeworks[7]=$iphoneframeworksroot/CoreAudio/
iphoneframeworks[8]=$iphoneframeworksroot/CoreData/
iphoneframeworks[9]=$iphoneframeworksroot/CoreFoundation/
iphoneframeworks[10]=$iphoneframeworksroot/CoreGraphics/
iphoneframeworks[11]=$iphoneframeworksroot/CoreLocation/
iphoneframeworks[12]=$iphoneframeworksroot/ExternalAccessory/
iphoneframeworks[13]=$iphoneframeworksroot/Foundation/
iphoneframeworks[14]=$iphoneframeworksroot/GameKit/
iphoneframeworks[15]=$iphoneframeworksroot/MapKit/
iphoneframeworks[16]=$iphoneframeworksroot/MediaPlayer/
iphoneframeworks[17]=$iphoneframeworksroot/MessageUI/
iphoneframeworks[18]=$iphoneframeworksroot/MobileCoreServices/
iphoneframeworks[19]=$iphoneframeworksroot/OpenAL/
iphoneframeworks[20]=$iphoneframeworksroot/OpenGLES/
iphoneframeworks[21]=$iphoneframeworksroot/QuartzCore/
iphoneframeworks[22]=$iphoneframeworksroot/Security/
iphoneframeworks[23]=$iphoneframeworksroot/StoreKit/
iphoneframeworks[24]=$iphoneframeworksroot/SystemConfiguration/
iphoneframeworks[25]=$iphoneframeworksroot/UIKit/
iphoneframeworks[26]=$iphoneframeworksroot/IOKit/

ssh root@$IPHONEIP "mkdir -p $iphoneframeworksroot"
scp -r /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk/usr/include root@$IPHONEIP:$iphonesdkroot
scp -r /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk/usr/lib root@$IPHONEIP:$iphonesdkroot

for index in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
do
echo "copying ${sdkframeworks[index]} to ${iphoneframeworks[index]}"
ssh root@$IPHONEIP "mkdir -p ${iphoneframeworks[index]}"
scp -r ${sdkframeworks[index]} root@$IPHONEIP:${iphoneframeworks[index]}
done

.
.
.

Wednesday, September 10, 2008

XCode Template for pwned iPhone 2.0.x

This is how to skip the Provisioning Profile in order to build & go in official sdk applications (not using toolchain headers) when you are not registered iPhone developer (US$99 program).

Here is how

(1) If you have an existing project from the Official Template, you need to change the code-sign identity and add two user-defined
settings in your Project Setting as below



Info.plist:Select all

"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Pwned Developer";
PROVISIONING_PROFILE_ALLOWED = NO;
PROVISIONING_PROFILE_REQUIRED = NO;


There are two instances for this part to change (one for Debug and another for Release)

(2)
Then amend the Info.plist of your project
and add these
Info.plist:Select all

<key>SignerIdentity</key>
<string>Apple iPhone OS Application Signing</string>


Then you can build & go your project with support of debug and setting break point like other registered iPhone developer

To use this method to build & go. You need
(1) Have a fake code sign identity called "iPhone Pwned Developer" in your Mac (if you have not already done so)

Here is the nice guide from Apple to create a self-signed identity
http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/chapter_3_section_2.html

updated link
http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW1

(2) You need to patch the MobileInstallation in your iPhone (if you have not already done so)
Here is how to patch the binary in iPhone and create backup first of course (the patch program is for iPhone which I compile from the source and supports 2.0 to 2.0.2)

Shellscript:Select all

wget http://www.cocoatouchdev.com/javacom/mobileinstallation_patch
cp -p /System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation /System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation.backup
chmod +x mobileinstallation_patch
./mobileinstallation_patch
ldid -s /System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation


The updated MobileInstallation patch, please use my package as posted here
http://hackint0sh.org/forum/showpost.php?p=340693&postcount=14

(3) You don't need to patch SpringBoard, as the changing of Info.plist has done this trick.


I have updated my XCode Template to 3.5.2

Please refer to this post for the instructions
http://iphonesdkdev.blogspot.com/2008/09/xcode-template-for-pwned-iphone-device.html


To use the "Open Tool Chain" template you need to install the open toolchain headers, run this shell script in your Mac

$ sudo mkdir -p /Developer/SDKs/iPhoneOS.sdk/Versions/iPhoneOS2.0.sdk/
$ svn co http://iphone-dev.googlecode.com/svn/branches/include-1.2-sdk
$ cd include-1.2-sdk
$ ./configure --prefix=/Developer/SDKs/iPhoneOS.sdk/Versions/iPhoneOS2.0.sdk/
$ sudo sh install-headers.sh


To test the new template "View-Based Application"
Create a new project from "View-Based Application" of "Application Pwned" and modified the ViewController file and implement the loadView as below, then Build & Go to your device.

You need to have the "iPhone Pwned Developer" certifcate in your Mac plus patch of MobileInstallation in your iPhone for successful build & go

ViewController.m:Select all

- (void)loadView {
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view = contentView;
[contentView release];
self.view.autoresizesSubviews = YES;
CGRect frame = CGRectMake(10.0, 10.0, 250.0, 100.0);

UITextView *textView = [[[UITextView alloc] initWithFrame:frame] autorelease];

textView.textColor = [UIColor blackColor];
textView.font = [UIFont fontWithName:@"Arial" size:18.0];
textView.backgroundColor = [UIColor whiteColor];

textView.text = @"This is the time for Developer to port all applications to firmware 2.0";

[self.view addSubview: textView];

}



Important Note
The template will fail to build & go when you change your build to iPhone Simulator and then switch it back to build & go to the iPhone device.

The error message is

CodeSign error: no provisioning profiles found for code signing identity 'iPhone Pwned Developer'


If this happens, the temporary solution is to

(1) Close the project file in Xcode
(2) Use Mac terminal to change directory to the project directory and remove the temp file in project file (e.g. if the Project is called HelloWorld)

cd HelloWorld
rm HelloWorld.xcodeproj/*.pbxuser

(4) Then open the xcode project file and build and go to device again.

For Firmware 2.1 & iPhone SDK (build 9M2517) for (2.0 & 2.1 development), please search this blog for updated trick

[How-to] Install gcc compiler and build toolchain app for pwned iPhone 2.0.x firmware

The gcc in iPhone procedure is updated here for the pwned iPhone firmware 2.0/2.0.1/2.0.2

If you install iPhone GCC, it is important to set root partition to about 700M in pwnage, if you set it too small your will get into trouble whenever there is an upgrade of GCC, as some of the libexec cannot be symlink to second partition.

You have to install the following packages in Cydia
  • GNU C Compiler 
  • iPhone 2.0 Toolchain 
  • Make 
  • Link Indentity Editor
  • wget (... in order to download the following sample in iPhone)
  • zip (... in order to unzip the following sample in iPhone)

then download the following zip file in your iPhone to test build your iPhone toolchain app

shellscript: Select all

wget http://www.iphone.org.hk/attach/38270-HelloWorld2.zip
unzip 38270-HelloWorld2.zip



shellscript: Select all

cd HelloWorld
make
make install


Restart your springboard, then you will have the HelloWorld app on your springboard

To uninstall HelloWorld.app
shellscript: Select all

cd HelloWorld
make uninstall

Stop The Device from Sleeping Programmatically

Select all

[[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ];

Add Organization name to Xcode Project

shellscript: Select all

defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions ' { "ORGANIZATIONNAME" = "javacom"; } '