2008年12月29日星期一

How-To compile iPhone Project in Mac using Makefile instead of Xcode and fake codesign and then install to pwned iPhone

[from: http://iphonesdkdev.blogspot.com/2008/12/how-to-compile-iphone-project-in-mac.html]
Here is an example to compile iPhone Project using Makefile instead of XCode.

The Makefile will compile and codesign the binary using ldid (Intel binary version) and then install the files directly to iPhone /Applications/ folder using ssh

Location of files
----------------
Classes : source code (.m .c .cpp etc)
Resources : png file and other support files
Project folder : *.xib Info.plist

(1) First you need to download this sample zip file and extract it to your Mac and cd to the directory


curl -O http://www.iphone.org.hk/attach/48150-PeoplePickerDemo.zip
unzip 48150-PeoplePickerDemo.zip
cd PeoplePickerDemo


(3) Change the IPHONE_IP in the Makefile to the IP address of iPhone, default is 10.0.2.2


Makefile: Select all

IPHONE_IP=10.0.2.2

SDKVER=2.0
SDK=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(SDKVER).sdk

CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1
CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-g++-4.0.1
LD=$(CC)

LDFLAGS += -framework CoreFoundation
LDFLAGS += -framework Foundation
LDFLAGS += -framework UIKit
LDFLAGS += -framework CoreGraphics
LDFLAGS += -framework AddressBookUI
LDFLAGS += -framework AddressBook
//LDFLAGS += -framework QuartzCore
//LDFLAGS += -framework GraphicsServices
//LDFLAGS += -framework CoreSurface
//LDFLAGS += -framework CoreAudio
//LDFLAGS += -framework Celestial
//LDFLAGS += -framework AudioToolbox
//LDFLAGS += -framework WebCore
//LDFLAGS += -framework WebKit
//LDFLAGS += -framework SystemConfiguration
//LDFLAGS += -framework CFNetwork
//LDFLAGS += -framework MediaPlayer
//LDFLAGS += -framework OpenGLES
//LDFLAGS += -framework OpenAL

LDFLAGS += -L"$(SDK)/usr/lib"
LDFLAGS += -F"$(SDK)/System/Library/Frameworks"
LDFLAGS += -F"$(SDK)/System/Library/PrivateFrameworks"

CFLAGS += -I"/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/"
CFLAGS += -I"$(SDK)/usr/include"
CFLAGS += -I"/Developer/Platforms/iPhoneOS.platform/Developer/usr/include/"
CFLAGS += -I"/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(SDKVER).sdk/usr/include"
CFLAGS += -DDEBUG -std=c99
CFLAGS += -Diphoneos_version_min=2.0
CFLAGS += -F"$(SDK)/System/Library/Frameworks"
CFLAGS += -F"$(SDK)/System/Library/PrivateFrameworks"

CPPFLAGS=$CFLAGS


(4) install respring utility in iPhone
make install_respring

(5) run make and make install
make
make install


(6) Test launch the app Demo in iPhone
.
.
.

In order to avoid typing the password using ssh, you can install the ssh public key of your Mac to your iPhone using the following method

(a) keygen in Mac terminal and type (if you haven't generated it before)
ssh-keygen -t rsa

You will be asked to enter a passphrase, please remember that if you enter that.

(b) create .ssh directory in iPhone (assume ip address of iPhone is 10.0.2.2) and in Mac terminal and type
ssh root@10.0.2.2 'mkdir -p .ssh'
then enter iPhone root password (alpine)

(c) copy mac public key to iPhone, and in Mac Terminal type
cat ~/.ssh/id_rsa.pub | ssh root@10.0.2.2 'cat >> .ssh/authorized_keys'
then enter iPhone root password (alpine)

(d) Edit the file /etc/ssh/sshd_config in iPhone

change these

#StrictModes yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys


to


StrictModes no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys


(e)reboot iPhone

没有评论: