A Simpler Hello World for the iPhone

by Erica Sadun

Although there's already a "hello world' floating out there for the iPhone, it involves a number of complicated classes. I decided to simplify and create a new "Hello World" from scratch based only on UIWindow, UIView and UITextView.

The code follows after the jump.


Neil Cowburn
2007-08-03 12:29:36
Cool! The next crucial step is getting the debugger attached to the app running on the iPhone :)
2007-08-03 14:16:59
I would love to see start to finish on the "hello world". Start with Get a Mac. Then list the tools needed and go from there. MAC rules!! I am a windows developer :(
Paul Howard
2007-08-04 13:56:21
Obviously, I'm going to need to learn Objective C.
2007-08-06 19:43:51
Shouldn't the pool be released on exit?
James Thiele
2007-08-15 13:31:02
Where does UIKit come from?
2007-08-20 10:24:00
Rob Terrell
2007-09-01 13:00:36
There's an error in the make file:

SampleApp: mainapp.o SampleApp.o

should be:

SampleApp: main.o SampleApp.o

Or you could rename main.m to mainapp.m. Either way.

2007-11-02 12:40:26
If you can make available a zip archive of all these source files, that would be helpful. Copied and pasted Makefiles don't work because they include spaces rather than tabs, and there may be other problems encountered when copying and pasting code that can be avoided if the sources can be downloaded.
2007-11-07 12:25:26
yes, please a 1.2.3 guide from start to finish would help for all us noobs getting into this
2007-11-14 12:19:22
This won't compile on my machine. i'm stuck. got 1.1.1 itouch jailbroke, v5 toolchain w/ PATH updated, took hello_src.zip as well as iPhoneHelloWorld.zip tried to compile hello_src (w/ updated makefile) and then the iPhoneHelloWorld (the code above, just from a zipfile - http://www.simplifymedia.com/misc/iPhoneHelloWorld.zip )

Some bits of the make errors:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h:60,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Components.h:32,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:85,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
from /usr/local/arm-apple-darwin/lib/gcc/arm-apple-darwin/4.0.1/../../../../arm-apple-darwin/include/CoreGraphics/CGEvent.h:17,
from /usr/local/arm-apple-darwin/lib/gcc/arm-apple-darwin/4.0.1/../../../../arm-apple-darwin/include/CoreGraphics/CoreGraphics.h:25,
from /usr/local/arm-apple-darwin/lib/gcc/arm-apple-darwin/4.0.1/../../../../arm-apple-darwin/include/UIKit/UIKit.h:3,
from mainapp.m:1:
/usr/include/sys/fcntl.h:418: error: parse error before __DARWIN_ALIAS_C
/usr/include/sys/fcntl.h:419: error: parse error before __DARWIN_ALIAS_C
/usr/include/sys/fcntl.h:420: error: parse error before __DARWIN_ALIAS_C
make: *** [mainapp.o] Error 1

any help appreciated. running 10.5.0 w/ Xcode 2.5 && 3.0 on 1stgen macbook pro.

2007-11-15 04:14:20
How can someone program with Objective C when there is Java?

Is like pilling a pineapple with your nails when you have a machine to do it sitting in your kitchen.

Serious: My time is precious and Java simplifies everything. The rest is history and toys for unproductive, poor nerds.

Sebastian Mecklenburg
2007-12-04 00:28:06

i can't compile too. first i get

i686-apple-darwin9-gcc-4.0.1: =: No such file or directory

and then a lot of errors like
/usr/include/unistd.h:509: error: syntax error before '__DARWIN_ALIAS_C'

any ideas?
regards + thanks in advance,

2008-03-07 14:24:39
I can see that you guys had this for long time, anyways, here is the official hello world :)