Native IPhone development using XCode, at last!

26 09 2007

So I got this fancy IPhone last week some time and have since been trying to get myself setup so I can start playing with native app development. The iphone dev. team has been making great strides but up until fairly recently, installing the toolchain has been rather daunting.

To keep this short and sweet, here are the steps I followed to get a working toolchain and XCode template:

1) Download the toolchain installer.

2) Download the toolchain helper. You’ll need an iphone connected. This little guy copies the essential files from your iphone onto your mac.

3) Run the toolchain helper. You’re phone will have to be ‘jailbroke’ for it to work. The simple answer, install AppTapp.

4) Run the toolchain installer.

5) Grab the XCode template. You’ll need to make a few changes to the template to work with your toolchain install.

5a) Open the xcode template project file in Xcode. The first thing you’ll see is that it can’t find Foundation.framework and UIKit.framework. You can fix these by right clicking them and choosing “Get Info”. Browse to your toolchain install and find the frameworks. For example, Foundation.framework is in “/usr/local/arm-darwin-apple/heavenly/System/Library/Frameworks”.

5b) Open Info.plist. Change the value of “CFBundleExecutable” to “«PROJECTNAME»”. Save.

6) Take a look at this thread and follow the directions provided by ‘rogerboesch’.

7) Grab Lucas Newman’s examples, unzip, open in XCode and build. SHAZAAM! If you want to test your app on the iphone, the easiest way I’ve found is to use AppTapp to install OpenSSH and then connect to the phone via ftp. Simply copy your app into Applications.

Hopefully it helps someone else! Big thanks to Lucas Newman and Roger Boesch. If you get stuck, leave a comment and I’ll do what I can to help.

Advertisements

Actions

Information

33 responses

29 09 2007
ecume des jours

unfortunately, those directions by ‘rogerboesch’ to get the new headers require a password. Perhaps berlios.de has now locked down their svn repository?

any ideas where those headers might otherwise be obtained?

30 09 2007
HooperX

Excellent write up! Nearly perfect, but I wanted to help others that will hit the snags that exist:

1) The link to rogerboesch’s LayerKit (headers) fix requires a workaround because if you follow his instructions as is, it will ask you for a password for SVN. *** A PASSWORD IS NOT REQUIRED *** Sorry, for the caps, but I finally figured out what the problem was.

you need to type the following line INSTEAD of rogerboesch’s version:
———————————————————–
sudo svn co http://svn.berlios.de/svnroot/repos/iphone-binutils/trunk/include include

expanding the link solves the whole problem of the password (I figured this out by getting to his repository without being asked for the password through a simple URL copy into the address bar)

2) In XCode, when you do a GetInfo on the red (broken) links for Foundation.framework & UIKit.framework, point each to the following locations:

Foundation.framework to: /usr/local/arm-darwin-apple/heavenly/System/Library/Frameworks/Foundation.framework
UIKit.framework to: /usr/local/arm-darwin-apple/heavenly/System/Library/Frameworks/UIKit.framework

(the important part is everything in the path AFTER /heavenly, in case you called it something other than “heavenly”)

Once I got those two snags out of the way, the FlipCoin sample compiled great in XCode and worked great on the iPhone.

Hope this helps 🙂

1 10 2007
john

Thanks HooperX!

2 10 2007
Adam

Great Job.

One thing i did notice. I had to point the two framework classes to the copies that i got from my iphone (The copies before i did a cp from src to /usr/local/blahblah)
I had to do this beasue when i do getInfo (in XCode) on framwork files the browser can not see most of the system files (usr, etc …) I was able to make it so Finder can see the files and folder but Xcode can still not.

Any ideas?

10 10 2007
Sean

Step 6 doesn’t quite work anymore. Take a look at this very nice and easy to follow presentation (via pdf) on developing for the iPhone and how to set it up: http://www.lucasnewman.com/phonedev.pdf

and, of course, enjoy!

11 10 2007
john

Sean –

I already have everything installed so I’ll take your word for it. That pdf is actually where I started, but I had skipped some of the info since I used the Iphone Helper app instead of manually copying my phone’s filesystem. I’d say that pdf is a better starting point and this post might be a useful reference for those that get stuck.

Adam –
I haven’t seen that behaviour. I simply had to point XCode to the proper frameworks. If you copy the filesystem elsewhere are you able to link up the frameworks?

john

19 10 2007
taco

Adam – in the open dialog, click in the search box top right and enter /usr to get into that normally hidden folder.

29 10 2007
Jim

I don’t know if this is because i use XCode 3, but i am getting a bunch of errors. the one the puzzle me the most is “libkern/arm/OSByteOrder.h: No such file or directory”.
Any help would be welcome.

31 10 2007
launay

Got the same error… sounds like xCode 3 is trying to use the wrong frameworh (Mac one and not iphone one)

31 10 2007
mardinemu

Is this Intel only? I’m getting an error on my PPC mac that says “Bad CPU type”…

5 11 2007
Adam Watkins

Unfortunately, I believe that the binary toolkit is Intel only.

5 11 2007
john

http://iphone.fiveforty.net/wiki/index.php/Toolchain_Project

Seems to be the completely manual way to get up and running, but the page does mention ppc.

6 11 2007
Adam Watkins

John, that page is out-of-date. Build instructions for the 0.3 branch are now found at:
http://code.google.com/p/iphone-dev/wiki/Building

It seems to all be progressing fine for me (with an iPod Touch and guessing what I needed to copy of the filesystem) but I haven’t actually finished compiling llvm-gcc.

11 11 2007
rasmus

Nice guide.
I have Xcode 2.5 installed and it seems that it’s a bit incompatible with this guide – I’ve had trouble when building the examples. Xcode couldn’t find the arm-assembler – it looks in /Developer/usr/libexec/gcc/darwin/* but the toolchain installs in /usr/libexec/gcc/darwin/arm/ – so I made a symbolic link to make it avalible to XCode: sudu ln -s /Developer/usr/libexec/gcc/darwin/arm /usr/libexec/gcc/darwin/arm/

Next problem is that I’m missing som headerfiles (building FlipACoin):

In file included from /usr/local/arm-apple-darwin/lib/gcc/arm-apple-darwin/4.0.1/../../../../arm-apple-darwin/include/LayerKit/LayerKit.h:
error: LKActionProtocol.h: No such file or directory
error: LKObjectProtocol.h: No such file or directory
error: LKTimingProtocol.h: No such file or directory
error: NSCopyingProtocol.h: No such file or directory

I’ve searched my entire hard drive – I don’t have ’em.

27 11 2007
OSX XCode で iPhone アプリ開発 | iPhone iPodTouch 脱獄囚日本語情報

[…] Native IPhone development using XCode, at last! « John Robinson 勝手意訳 iPhoneDevチームがかなり頑張ってくれたおかげで開発しやすくはなったけど、結構厄介。 簡単に環境を整えるステップの紹介 試してみたけどちょっと情報が古くなってるのかなiTunesのバージョンとかがあわないみたい、、、Apple公式のSDKを待つか、、、 […]

30 11 2007
jlongman

re: OSByteOrder, follow these directions I found on the net:

I’m still trying them but I got at least past the OSByteOrder

30 11 2007
jlongman

hmmm… I used the above directions and then later attempted the toolchain after I had problems with compiling some of the demo-apps. I later repeated the”make install” stages of the above instructions, which leads me back to the same point: Motion builds but NetServices and FlipACoin fail.


Checking Dependencies

ExternalBuildToolExecution FlipACoin
cd /workspace/iphone/phonedemos/FlipACoin
/usr/bin/make
mkdir -p /workspace/iphone/phonedemos/FlipACoin/build/FlipACoin.build/Release/
/usr/local/bin/arm-apple-darwin-gcc -g -O2 -Wall -c /workspace/iphone/phonedemos/FlipACoin/FCCoinView.m -o /workspace/iphone/phonedemos/FlipACoin/build/FlipACoin.build/Release/FCCoinView.o
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:19: error: syntax error before 'GSEventRef'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m: In function '-[FCCoinView flip]':
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:51: warning: 'LKKeyframeAnimation' may not respond to '-setValues:'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:51: warning: (Messages without a matching method signature
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:51: warning: will be assumed to return 'id' and accept
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:51: warning: '...' as arguments.)
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:52: warning: 'LKKeyframeAnimation' may not respond to '-setKeyTimes:'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:59: warning: 'LKKeyframeAnimation' may not respond to '-setValues:'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:60: warning: 'LKKeyframeAnimation' may not respond to '-setKeyTimes:'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:67: warning: 'LKKeyframeAnimation' may not respond to '-setCalculationMode:'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:73: warning: 'LKKeyframeAnimation' may not respond to '-setValues:'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:74: warning: 'LKKeyframeAnimation' may not respond to '-setKeyTimes:'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m: In function '-[FCCoinView _showResults]':
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:122: warning: passing argument 2 of 'setValue:forKey:' from incompatible pointer type
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:123: warning: 'LKLayer' may not respond to '-setOpacity:'
/workspace/iphone/phonedemos/FlipACoin/FCCoinView.m:128: warning: 'LKLayer' may not respond to '-setOpacity:'
make: *** [/workspace/iphone/phonedemos/FlipACoin/build/FlipACoin.build/Release/FCCoinView.o] Error 1

1 12 2007
jlongman

Basically it looks like I’m missing headers. I updated the code to include the proper frameworks and includes, and I started looking at the iAppADay code, but I simply just don’t have WebCore/* and WebKit/* and so on.

2 12 2007
nixopho

Got it up and running, but have an strange issue when building,

cannot find the as assembler for arm, is this not provided by the toolchain ?

6 12 2007
SalukiTKE

I am having the same assembler problem.
as: assembler (/Developer/usr/bin/../libexec/gcc/darwin/arm/as or /Developer/usr/bin/../local/libexec/gcc/darwin/arm/as) for architecture arm not installed

What can I do?

9 12 2007
nixopho

installed the toolchain through Macport resolved my issue

Note: had to make a few path modifications.

22 12 2007
oho

I guys I have succeed in compiling the demo FlipACoinApp using code.google toolchain http://code.google.com/p/iphone-dev/wiki/Building
But I guess whatever toolchain you are using, you might succeed compiling as long as you :
1) add #import
2) comment the line [textLabel setFont:(GSFontRef)[(id)GSFontCreateWithName(“Marker Felt”, kGSFontTraitBold, 50.0) autorelease]];
For somme reasons GSFontRef bring an error. I couldn’t find a header that would make it compile with this line (even CoreGraphics/CGFont.h didn’t help!).

the app works even if you comment the line.

oho

22 12 2007
oho

sorry the point 1) is #import

22 12 2007
oho

#import \

22 12 2007
oho

sorry for coments pollution : I’m not good as bloging …
so code wasn’t submit when using “inferior and superior signs
#import

22 12 2007
oho

#import “”

22 12 2007
oho

ok I give up !
#import GraphicsServices/GraphicsServices.h

28 12 2007
Jack

To oho: If GSFontRef generates an error, replace your GraphicsServices/GraphicsServices.h by the one from http://svn.berlios.de/svnroot/repos/iphone-binutils/trunk/include/. This one seems to be more complete than the one delivered with the toolchain.

(I got this hint from http://www.cocoadev.com/index.pl?GSFont).

28 12 2007
Thorsten

Dear guys,

I’m not a software developer at all and I won’t become soon. But I tried several hours to set up a toolchain environment here to try to compile some stuff (just for fun). It seems I am not even understanding enough of what I try to do to succeed. Therefore, please allow mw to ask here:
Can Darwin applications in any form be compiled to run on OS X 1.0 (iPhone)? I am asking in regard of one special application: macfuse. I though, it might be worth a try to compile that tiny peace of software to be able to (over?)mount the iTunes stuff in the iPhone from a WiFi source, let’s say a high harddrive.
Can anyone please answer me at tboege ” at ” web.de (in CC to this page here)?
Thanks a lot!!! And please don’t mind if this was not a good choice where and whom to ask, anyway…
Thorsten

6 01 2008
Ben S. Stahlhood, II

Hey guys,

You can check out a new guide and XCode template for doing iPhone UI Kit applications, at my blog http://www.cocoamachine.com/blog/. The template lets you build right from the project wizard and it will copy your app to the phone for you and reboot spring board. Enjoy!

21 02 2010
Appewsmunse

How’s things!

How is everybody? I’m unfamiliar here!

Chau…

Cristy
Web Video

29 01 2011
[iPhone] xcodeでプログラミング « sonson@Picture&Software

[…] ファイル自体は,すでに作られているみたい.さらに解説もある. ・https://jrobinsonmedia.wordpress.com/2007/09/26/native-iphone-development-using-xcode-at-last/ ・http://max.iamas.ac.jp/2061/articles/645.html […]

29 01 2011
[iPhone] LeopardでXCode3.0で開発環境を修復する « sonson@Picture&Software

[…] パッケージでインストール.これは,この辺で. 3.Macportsがない場合は,インスコ 4.heavenlyをセットアップ. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: