Reply
   
 HOWTO compile iPhone applications using traditional development tools 
 
 
  #1 (permalink)  
Old 11-11-2008, 04:24 PM
Regular

Group: Regulars
Location: New Hampshire, USA


HOWTO compile iPhone applications using traditional development tools

From my original webpage, here.

HOWTO compile iPhone applications using traditional development tools
I prefer to use quite traditional UNIX development tools for my application development - vi, make, and gcc (yes, you may prefer emacs). Of course each of these is readily provided under OS X but, when it comes to iPhone development, we're dissuaded from using these traditional tools in favour of the GUI-based XCode environment.

There is a wealth of information and noise on the web devoted to developing iPhone applications in a jailbroken world. The volumes of commentary on copying SDK headers, extracting the root-filesystem, bypassing code signatures, self-signed code, pseudo signing, disabling firmware checks, SpringBoard patching, and executable entitlements, is daunting. Moreover, one critical tool, ldid, remains poorly written and its only diagnostics are issued via its code's assert statements.

Unfortunately, much of this commentary is outdated, undated, confusing, and offers attractive red-herrings to those just starting out. Much of it was written prior to the lifting of the NDA, and describes long-past hacks for previous versions of the iPhone firmware and SDK.

This HOWTO outlines how to continue using traditional development tools.
It will have limited utility for most iPhone developers but, as it took me several frustrating hours to locate, distill, and test this information, I hope that I can save others some time.

Assumed environment
  • an Apple Macintosh computer, running OS X 10.5.5,
  • the XCode 3.1.1 Developer Tools,
  • the iPhone SDK for iPhone OS (2.1 or 2.2), and
  • a jailbroken iPhone (hereafter I will not explicitly mention iPod Touch) running firmware 2.1 or 2.2.

How you get your development environment to this level, legally or illegally, is up to you - but please don't ask me how to do so illegally.

Preparing your iPhone
Firstly, on your jailbroken iPhone, add the new source www.iphone.org.hk/apt/ to Cydia:
Cydia -> Manage -> Sources -> Edit -> Add
Then, when this source is entered and Cydia has been refreshed, install the two packages named:
  1. MobileInstallation Patch, and
  2. Link Identity Editor.
Configure your iPhone to trust your Macintosh
It is widely known that the root password on jailbroken iPhones is alpine, but it's inconvenient to have to type this many times during application development. Instead, we use the related commands ssh to issue commands on our iPhone, and scp to copy files to our iPhone.

The necessary steps to enable this are best described as steps (a)-(e) in the section commencing "In order to avoid typing the password using ssh...." from this blog.

Preparing your Macintosh
There's not much to do here. Most effort is usually devoted to locating all of the necessary files and directories amongst the /Developer directory, but the necessary information can best be provided through a generic Makefile (download here) :

Code:
# the IP address of your iPhone or iPod Touch
DEVICE	= 10.1.1.3

APPL	= MyApp

DOTH	= MyApp.h
OBJS	= main.o MyApp.o

TGZFILE	= $(HOME)/backup/MyApp.tgz

# ----------------------------------------------------------------------

SDK	= /Developer/Platforms/iPhoneOS.platform/Developer
ARCH	= armv6
#SYSROOT	= $(SDK)/SDKs/iPhoneOS2.1.sdk
SYSROOT	= $(SDK)/SDKs/iPhoneOS2.2.sdk

CC	= $(SDK)/usr/bin/arm-apple-darwin9-gcc-4.0.1 \
		-arch $(ARCH) -isysroot $(SYSROOT)
CFLAGS	= -std=c99 -Werror -I$(SDK)/usr/include/gcc/darwin/4.0

LD	= $(CC)
LDFLAGS	=\
	-framework UIKit\
	-framework CoreFoundation\
	-framework Foundation\
	-framework CoreGraphics\
	-lobjc\
	-bind_at_load

# ----------------------------------------------------------------------

$(APPL):	$(OBJS)
	$(LD) $(LDFLAGS) -o $@ $^
	cp $(APPL) $(APPL).app
	@chmod 755 $(APPL).app/$(APPL)
	@touch $(APPL).app

%.o:    %.m $(DOTH)
	$(CC) $(CFLAGS) -c $<


install: $(APPL)
	@ssh root@$(DEVICE) /bin/rm -f /Applications/$(APPL).app/$(APPL)
	scp -r $(APPL).app root@$(DEVICE):/Applications
	ssh root@$(DEVICE) /usr/bin/ldid -S /Applications/$(APPL).app/$(APPL)  

uninstall:
	ssh root@$(DEVICE) /bin/rm -rf /Applications/$(APPL).app

clean:
	rm -f $(APPL) $(APPL).app/$(APPL) *.o f?

backup:
	make clean
	tar zcvf $(TGZFILE) .
	@ls -l $(TGZFILE)
Compiling and installing your application
This HOWTO is not intended to be an introductory tutorial for iPhone and Objective-C development.
However, to test that your development platform is ready, an introductory application named MyApp may be downloaded from here.

  • Create a new directory and unzip MyApp.zip therein.
  • Type make - there should be no errors reported.
  • Ensure that your iPhone's WiFi (and possibly VPN) are turned on.
  • Type make install - there should be no errors reported.
  • The first time that you install MyApp its icon will not appear on the iPhone - you will need to restart (or respring) SpringBoard to display the icon. If you plan on a lot of future development, use Cydia to install the package named Respring. This provides a simple one-touch application to restart SpringBoard.
  • Run MyApp on your iPhone - it does nothing but count!
  • When you've had enough fun, type make uninstall.

That's it!
Suggestions on how to improve this document are most welcome.
Good luck,
__________________
24" 2.4GHz iMac, 2GHz MBP, (1.66GHz, 250GB mini + Dell 2405FPW + Belkin F1PI241EGau), 16GB 1stG 'Touch

Last edited by chrism238; 30-11-2008 at 09:18 AM.
chrism238 is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #2 (permalink)  
Old 17-11-2008, 06:31 PM
Regular

Group: Regulars
Location: New Hampshire, USA


A solitary bump.
Currawong has been busy this past week, and so the approval of my article was "lost in time".
Hopefully of interest to some
__________________
24" 2.4GHz iMac, 2GHz MBP, (1.66GHz, 250GB mini + Dell 2405FPW + Belkin F1PI241EGau), 16GB 1stG 'Touch
chrism238 is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #3 (permalink)  
Old 21-11-2008, 12:19 AM
Member

Group: Regulars
Location: Perth, Western Australia


This is a great article, well written and informative.

It has the nerd in me wanting an iPod Touch...
__________________
Flickr / Blog / Site
gregh is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #4 (permalink)  
Old 30-11-2008, 09:27 AM
Regular

Group: Regulars
Location: New Hampshire, USA


(Thanks Greg ).

I've trivially updated my article to reflect the fact that it all still works once you've updated your device to iPhone OS 2.2 and installed the iPhone SDK 2.2 on your Mac.

(of course, if you have a locked iPhone 3G, don't let my article so enthuse you into using QuickPwn to jailbreak 2.2 )
__________________
24" 2.4GHz iMac, 2GHz MBP, (1.66GHz, 250GB mini + Dell 2405FPW + Belkin F1PI241EGau), 16GB 1stG 'Touch
chrism238 is offline
Profile CardPM
Go to the top of the page
Reply With Quote
 
Reply

Thread Tools

 
Similar Threads
 
Thread Thread Starter Forum Replies Last Post
Scared to upgrade your 1st-Gen iPhone to v2.2? MacTalk can do it for you! decryption iPhone & Mobile Phones 102 07-01-2009 02:28 AM
My 1st week my with new iPhone Rogerthatv2 iPhone & Mobile Phones 18 02-01-2009 12:21 PM
APC's 10 Reasons the iPhone Sucks - Rebuttal decryption iPhone & Mobile Phones 125 01-01-2009 11:38 PM
Apple Newton, Palm Pilot, Now iPhone, Are The Applications XL? Sync? Novatian iPhone Software & App Store 2 05-11-2008 01:50 PM
Software unlocking an iPhone (with 1.0.2 firmware) in OS X and modifying it for use i decryption Articles, How-to's and Reviews 6 14-11-2007 11:23 AM