Iphone development
MAD-IP

Philippe Possemiers 8 march 2009

So what is all the fuss about?
Touchscreen interface, with several patents Visual voicemail Full MacOSX instead of subset (half a Gb) Webbrowsing with most advanced webbrowser to date on handheld device (Safari) Synchronisation via ITunes => demo

© artesis 2008 | 3

11b/g) Bluetooth 2. with 3:2 aspect ratio Input devices: Multi-touch screen interface plus a "Home" button and "Sleep/Wake" located on the top of the iPhone.Features Screen size: 3.0 with EDR 20Hz to 20kHz frequency response (both internal and headset) © artesis 2008 | 4 . non-removable battery 2 megapixel camera Location finding by detection of cell towers and Wi-Fi networks Samsung S5L8900 (412 MHz ARM 1176 processor. Built-in rechargeable. PowerVR MBX 3D graphics co-processor) Memory: 128 MB DRAM Storage: 8 GB or 16 GB flash memory Operating System: iPhone OS Quad band GSM / GPRS / EDGE: GSM 850 / 900 / 1800 / 1900 Wi-Fi (802.5 in (89 mm) Screen resolution: 480×320 pixels at 163 ppi.

5 (3G) or 6 (Wi-Fi) hours of Internet use.3 mm) (d) Weight: 133 g Headphone jack (non-recessed) Battery has up to 10 hours of 2G talk. lasting over 300 hours on standby.48 inch (12. 5 hours of 3G talk.1 mm) (w) × 0.5 inches (115.Features new generation Color: Black (8 GB or 16 GB) or white (16 GB) Size: 4.5 mm) (h) × 2. 7 hours of video playback. and up to 24 hours of audio playback.38 W/kg © artesis 2008 | 5 .4 inches (62. 3G for broadband data speeds Assisted GPS Digital SAR Rating: 1.

2008 (launch) : 552 Apps December 5.000 Apps / 500M downloads © artesis 2008 | 6 .Popularity iPhone Stats October. 2008 : 300M downloads February. 2009 : 20. 2008 10 Million iPhones App store stats July.

Openness iPhone Open Source Write anything you want Device Homogeneity NO NO YES Android YES YES NO Closed source with open source components. (Benevolent) Vertically Integrated Dictatorship vs. Open Source. this is likely to stay this way. Loosely-Controlled Ecosystem © artesis 2008 | 7 . Given Apple’s history.

com/iphone/ Download iPhone SDK.Where to start? http://developer. if you are a Registered iPhone Developer or enrolled in the iPhone Developer Program SDK includes : Xcode IPhone simulator Monitoring instruments Interface builder • loading an application onto devices is only possible after paying a Apple Developer Connection membership fee of 99 $ (standard) or 299 $ (enterprise) • => XCode demo : UDecide © artesis 2008 | 8 .apple.

shockwise.Web apps • http://www.com/iphone/draw.apple. of which they will receive a 70 percent share • Developers can also opt to release the application for free and will not pay any costs to release or distribute the application beyond the membership fee © artesis 2008 | 9 .php Developers are free to set any price for their applications to be distributed through the App Store.com/webapps/ http://www.

and the vibration function should only be used for alerts © artesis 2008 | 10 . for basic reliability testing and other analysis Applications may be rejected if they are of only "limited utility" Toolbars must be placed at the bottom of the screen.Web Apps Applications are downloaded directly to iPhone or iPod Touch App Store is also available within iTunes Applications are subject to approval by Apple. as outlined in the SDK agreement.

How do we develop Apps for the iPhone? We can use Xcode / Objective C We can develop AJAX / Javascript applications that can be accessed through Safari We can use Java AlcheMo for iPhone Xmlvm We can install Java on an unlocked and Jailbroken iPhone © artesis 2008 | 11 .

© artesis 2008 | 12 .Objective C 1980S : Objective-C language designed by Brad J. Cox: –Object-oriented extension of C. –Strict superset of C. Inspired by Smalltalk. Use for OS X. OPENSTEP now called Cocoa. 1988 : NeXT Software licenses the Objective-C language and develops NEXTSTEP 1992 : FSF adds Objective-C to GNU compiler suite 1994 : NeXT Computer and Sun Microsystems release a standardized OPENSTEP specification 1996 : Apple acquires NeXT Software.

-(int) numerator.h> @interface Fraction: NSObject{ intnumerator. -(void)setNumerator: (int) d. intdenominator.Objective C Interface (. }-(void) print. -(int) denomin@end © artesis 2008 | 13 .h) #import <Foundation/NSObject. -(void)setDenominator: (int) d.

}@end © artesis 2008 | 14 . } -(int) numerator { return numerator. } -(int) denominator { return denominator. numerator.h> @implementation Fraction -(void) print { printf("%i/%i".Objective C Implementation (. } -(void) setDenominator: (int) d { denominator = d. denominator).m) #import "Fraction. } -(void) setNumerator: (int) n { numerator = n.h“ #import <stdio.

nor do the requests need to be asynchronous. web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page. very rich and native looking Apps are possible © artesis 2008 | 15 . Applets were the precursors of AJAX With iPhone Safari browser.AJAX & JavaScript AJAX (Asynchronous JavaScript and XML) : a group of interrelated web development techniques used to create interactive web applications or rich Internet applications. With Ajax. The acronym AJAX has thus changed to the term Ajax. which does not represent these specific technologies. Despite the name. the use of JavaScript and XML is not actually required.

net/articles/iPhone.google.com/p/iui/ • Create Navigational Menus and iPhone interfaces from standard HTML • Use or knowledge of JavaScript is not required to create basic iPhone pages • Ability to handle phone orientation changes • Provide a more "iPhone-like" experience to Web apps (on or off the iPhone) © artesis 2008 | 16 .aptana.NET AJAX is supported : http://steveorr. Based on the work of Joe Hewitt who developed the free Facebook iPhone App.aspx Native look and feel screen controls : IUI. • http://code.com/#Home ASP.morfik.AJAX & JavaScript AJAX plugin for eclipse or standalone version : http://www.com/ Morfik also has an IDE : http://www.

it was adopted by Gecko browsers (notably Mozilla and Firefox) and standardized by the WHATWG on new proposed specifications for next generation web technologies. Later. powering applications like Dashboard widgets and the Safari browser. animations. Some anticipated uses of the canvas include building graphs. and image composition. Support is also present in the Opera 9. It was initially introduced by Apple or use inside their own Mac OS X Webkit component.AJAX & JavaScript The canvas element is a third party extension that allows for dynamic rendering of scriptable bitmap images. Canvas consists of a drawable region defined in HTML code with height and width attributes.0 browser. thus allowing for dynamically generated graphics. JavaScript code may access the area through a full set of drawing functions similar to other common 2D APIs. No need for flash anymore! © artesis 2008 | 17 .

damonkohler.AJAX & JavaScript Demo based on http://www.html © artesis 2008 | 18 .com/2008/12/javascript-painting-withcanvas.

benjoffe.AJAX & JavaScript Demo based on http://www.com/code/demos/canvascape/ © artesis 2008 | 19 .

html alcheMo for iPhone is capable of converting J2ME applications utilizing an extensive subset of Java ME CLDC 1.innaworks.AlcheMo for iPhone http://www.1 (http://java. Additional APIs support multi-touch and native iPhone look and feel.sun.com/products/cldc/) and MIDP 2.0 (including touch screen support) and supports several JSR extension APIs (http://jcp. repeatable. and available 24/7 while requiring no iPhone specific experience. © artesis 2008 | 20 . This automatic translation process is instantaneous.org/en/jsr/detail?id=198) including the JSR-256 mobile sensor API.com/alcheMo-for-iPhone.

. installing..(real) Java on the iPhone No official support It is however possible to run Java on the iPhone We have to pull some tricks. Apple has stated it will not design software updates specifically to break native applications other than applications that perform SIM unlocking © artesis 2008 | 21 . jailbreaking.

iphone-dev. Unlocking is the process by which a mobile device is made compatible with telephone networks it was not specifically licensed to be used with.org/) Pusher. bypassing Apple's code distribution mechanism (the iTunes App Store and the iTunes Application). Tools : PwnageTool. redsn0w (http://blog. It is a specific form of privilege escalation. from the iPhone Dev Team (http://blog.Unlocking & Jailbreaking Jailbreaking is distinct from "unlocking".iphone-dev.org/) © artesis 2008 | 22 .iphone-dev. In the context of the iPhone.org/) QuickPwn.php/Main_Page) ZIPhone (http://www. A jailbreak is the act of breaking out of a jail in UNIX-like operating systems or bypassing digital rights management (DRM). from RiP Dev (http://ripdev.org/) Yellowsn0w.com/pusher/) Linux on iPhone (http://www. from the iPhone Dev Team (http://blog.iphonelinux. it allows the user to run arbitrarily defined code or applications.ziphone.org/index.

IPhone in Finder • • • • • Install AFP (Apple Filing Protocol) on your iPhone Get your iPhone's IP address Connect to server from MacOSX Finder afp://ip-address-of-your-iphone User : 'root' / pwd : 'alpine' © artesis 2008 | 23 .

App Store applications are located in /var/mobile/Applications/ Cydia is a front end/graphical interface for a port of APT created by Jay Freeman Cydia allows users to add custom sources. so people can choose where to download software from © artesis 2008 | 24 . in the same place where 'Apple' native applications are located. custom wallpapers (themes) and battery status apps The applications are downloaded directly to iPhone or iPod Touch and are located in the /Applications/ directory . this allows iPhone users to bypass Apple's restrictions on certain kinds of applications. such as launchers.Cydia Cydia is a package manager for installing unofficial 3rd-party applications on the iPhone Among other things.

was Nullriver.0 firmwares. created and maintained by the Russian Rip-Dev company alongside other tools. on pre 2. © artesis 2008 | 25 .Installer Installer is another package installer. Inc. The former maintainer of Installer.

install Terminal. libraries etc. go to Java section and select iPhone/Java which will install the virtual machine. You can upload Java files to iPhone using iPhone Browser => demo Run Terminal (installed above) and use java (jikes) compiler to compile your program. Also. Then install Jikes (java compiler). For example: jikes -cp /usr/lib/rt.jar MyFirstJavaProgramForIPhone.(real) Java on the iPhone Run Cydia Installer.java You can run the class file as usual: java MyFirstJavaProgramForIPhone © artesis 2008 | 26 . Now restart iPhone.

Based on the XML-document generated by the front-end. and XPath. This allows manipulation and translation of XMLVM-based programs using advanced XML technologies such as XSLT. various transformations are possible : Cross-compilation from .xmlvm.XMLVM http://www.NET to JVM byte code Java or . XQuery.org/overview/ XMLVM translates a Java class file (or a .NET applications to JavaScript so that they can run as AJAX applications in any browser Cross-compilation of Java programs to Objective-C to create native iPhone applications Cross-compilation of Android applications to run on the iPhone © artesis 2008 | 27 .NET executable) to an XMLdocument.

XMLVM © artesis 2008 | 28 .

XMLVM © artesis 2008 | 29 .

origin. window.y = 0. rect. public class HelloWorld extendsUIApplication { public voidapplicationDidFinishLaunching(NSNotification n) { CGRect rect = UIHardware. } } © artesis 2008 | 30 . UIView mainView= newUIView(rect). UIWindow window = newUIWindow(rect). window.fullScreenApplicationContentRect()._setHidden(false).orderFront(this). _title.setContentView(mainView).HelloWorld in Java import org.origin. _title.setText("Hello World!").setCentersHorizontally(true).xmlvm. window.x = rect. UITextLabel _title = new UITextLabel(rect). window.iphone. mainView.makeKey(this).*.addSubview(_title).

UIWindow* window = [[UIWindow alloc]initWithContentRect: rect].origin. [window _setHidden: false].x = rect. [_title setText: @"Hello World!"]. rect.HelloWorld in Objective C @interface helloWorld : UIApplication -(void) applicationDidFinishLaunching: (NSNotification) n. UIView* mainView = [[UIView alloc] initWithFrame: rect]. [mainView addSubview: _title].y = 0. UITextLabel *_title = [[UITextLabel alloc]initWithFrame: rect]. [window makeKey: self]. }@end © artesis 2008 | 31 . @end @implementation helloWorld -(void) applicationDidFinishLaunching: (NSNotification) n {CGRect rect = [UIHardware fullScreenApplicationContentRect].origin. [window setContentView: mainView]. [_title setCentersHorizontally: true]. [window orderFront: self].

class To write the Objective-C source code to a file.m © artesis 2008 | 32 .class The previous command will generate two files: –${workspace_loc:xmlvm}/tmp/HelloWorld.class To cross-compile the XMLVM to Objective-C use: --console --objc ${workspace_loc:xmlvm}/bin/org/xmlvm/test/iphone/ HelloWorld.Crosscompiling HelloWorld.java to Objective-C The cross-compiler is in source folder src/xmlvmclass org.Main To generate the XMLVM for “Hello World” use the following command line options (under Eclipse): --console ${workspace_loc:xmlvm}/bin/org/xmlvm/test/iphone/ HelloWorld.h –${workspace_loc:xmlvm}/tmp/HelloWorld.xmlvm. use: --out=tmp --objc ${workspace_loc:xmlvm}/bin/org/xmlvm/test/iphone/ HelloWorld.

The previous command can be accomplished by either ssh-ing (secure shell) into the iPhone. type “killall SpringBoard” . © artesis 2008 | 33 . or by using a terminal application on the iPhone. Restarting the SpringBoard is necessary only once so that it picks up the new “Hello World” application.Compile and run HelloWorld Type “make” in ${workspace_loc:xmlvm}/tmp Type “make deploy” On the iPhone.

End (for now) Questions? Remarks? © artesis 2008 | 34 .

70.9.//8 -0.74889028700.3/$:3. $97.3:.3/.80.0380890 -0.4.98:50780941 0%$419.0 .0458%$%! $.9.6:7080%$419.3/ /0.3:.0/0830/- 7.0.425078:90 0%425:907.1. 89..70 &80147 $  !$%! 34.79088   ./ 4 -0.9. ...0 .0 94&.0  $ -0.9.9.7/0/ !$%!850.-0.9 470390/090384341 38570/-$2.0/4.943 550.

-0.9.0  254794:3/.0 39071..943.

9  39071.4/ 80903423...4/ 5739 .$ -0.943$ -0.947 39 / 39 3:207.9 393:207.79088   .07.947 39/03423.947 < .947 39 / .4/ 809:207.947 39 /0342303/ .

-0.9.943 2 254797..943  2547989/4  2502039.943 .9437..0 2502039.4/ 5739 57391 .

9473< .947 709:73/03423.947 709:733:207. 3:207.79088   .4/ 80903423.947 39 / /03423.947/< 39 /03423.947 39 3 3:207.4/ 809:207.947 < .947 /03423.947<03/ .947< 39 3:207.

55.759..3/8 349. 0- .00- ...077.7434:8  %0.9438477...36:08:80/94.70 5488-0 .1.3/-0.30/94909072.0/.7434:8390 -...3907309. .89:8.370970./408 3497057080399080850..474190 08935.9438 9.74:3/94:939071073990/85.83.903907.55.$...7-74807 .9:.9.83.7432.7434:8.90/ 0-/0.0443558..$.9.9438.0 08590903.90..:7847841 9!430$.706:70/ 347/490706:0898300/94-0.174290807.045203990.34408 5509807090570.55.3/3.79088   .759. .74:541390770.9..20 90:8041.1....$.70.3/ .759  83...07.

$.759 5:31470. .07843995.3/.5804789...430.

.

3. .42. .59.

8.84.3995. 471.

.

42. 2471 .

420 $! %88:554790/995.

.

0477 309.890.

08..79.

0-44!43055 W 995.439748& .!430 ..3/1008.044.0450/901700.7003.85 .9.80/4390474140 0994/0.

.

42.4/0 440 ..

5.

:.

08 W -994..943.7598349706:70/94.90-.7/ % W &8047340/041.. W 70.03:8....3/.943.308 W !74.70.558 4347411 90!430  ../0.0940-.08174289.8.2470!430 0050703.3/0543047039.79088   . !4305.3/!43039071.$.90.

 -74807  ../4590/-0.2.8.90/:8084190. 974:.3.7/0/-90%43305745480/850.2.. 703/073418.97/5.7909038439..31:3.759.42548943 4300/1471.4-748078 349.9..1.3/7014 .42543039 54073 . .-07043/0130/3%.94380.0/- 55047:8038/090743.3.3974/:.79088   ..48147/3.839.90/7.7//098.943882.52.8.3/2.7944907.4/02.845708039390 507.759...32470 .5.907 9 .8-4.9438  .5..$. $0-9.08890...3/90$..1...3//9.55.8 $420 ..39.32.08 9.9430-90.34408 $:554798.:/0-:/37.-0-92..70.0307..7-74807 .3.8.4/09 09.0./7.9438147 3090307.3/ 89.$.-4.83.997-:908 .43147/3.80020398.759 %0.58 .3/..42243 !8 9:8..1:80941/7.43889841.

80/43995..759 024-. ..$.

.

 /.42.243407 .

 .

.

.8..3...393 9 .8 92 .759 5..79088   .

..80/43995.$. .759 024-.

.

42. -034110 .

4/0..

/0248.

50....3..8.

79088   . .

.04147!430 995.

.

478 .42. 33.

309038..55.5.43.04147!4308...08:-80941..-041.9438 :93.  995.0793..04 147 !430 92 ...

.

... 8:3 .42.

574/:.98.

./.

3/8:55479880.70038:55479 .:/394:. 8. .07.$#0903843!8 995.3/!  3.

.

.5 47.

03.

87.

9.:942.9..0888389.0!430 44.97.:/390$# 24-0 803847! //943.38.3/100 %8..-0 ./09.3/3.304:8  7050.-0..943574.3/.39.!88:554792:9 94:../ 3.9.

0706:7334!430850.0 .79088   . 050703.1.

3 .0945:842097.. .-70.79088   .8 .9.90/9349/0838419...0.4390!430 4411.943849079.55.3.55...8:55479 9840.1.4390!430 0.908850..889..075488-0947:3.94 -70.3 389.94389..70..3 550.70:5/.95071472$ :34.3.

7-97.425..3890574.&34.082..943 %448 !3.9438 -5../0.3& 04507.-70.7 /0130/.850.0%44 174290!4300...943 390.55.%0.7982.9-0990054303094789.3.890.941-70.883550 8.38/893.9388902847 -5...883/9.3 &34.00 08.4890:807947:3.2 995.34:941.1.8349 850..02039 # 98.088-.-70.91742:34..3/90%:30855..-70.14724157.4/047.0380/94-0:80/9 .3 .3 . 24-0/0.439094190!430 9..4/0/897-:94320.382 90%:30855$9470.1.

.

-4 5430 /0. 47.

":.%0.2 995.!3 174290!4300.

.

-4 5430 /0. 47.

 0483  70/83  995.

.

47.-4 5430 /0.

!:807 1742#!0. 995.

.

42.75/0. .

5:807.

3:43!430 995.

.

 54303: 47.

3/0 55.

3*!..0 !430 995.

.

 5430 47.

79088   . .

//7088 4330.994807..! 5503!7494.!43033/07 W W W W W 389. $3/07 .071742.15.4 434:7!430 094:7!430 8!.

.

5 .//7088 41 4:7 5430 &807 7449 .

5/ .79088   .530 .

990789.9:8. /.48!430:807894 -5.55.55..33/841 .8..3/-..55./0//70.943843.:3.3....5. 7/ 5.94384390!430 2434907938 98.5078 90208 ..88550 870897..02.9438 8:.078 .5.3/.70/434.8.3:3411.558 %0.79.:8942.704.9438.90/390..079./.07147389.994!430 47!4/%4:.

.55.9438.

90/3.0 ...947 3908.9.. /70.9438.70 4.9438.55..205.90/ 55$9470.55.0070 550 3..704.

..7.

24-0.

55.9438..

/.1743903/.8.

70 1742 .:894284:7.3.79088   ..547941 !%.70.7.448007094/434..7002..90/-..39071.08 84 50450.3 /./8419.0147.//.48:807894.5.

389.90/.30741389.3/2.0389. .078.07 43570  172.07 389.70.708 .30/-90#:88.425.8:7.3 #5 0.349075.07  ..39...07 3.79088   .3.438/049079448  %01472072.39.

.70..80.07 494.9!430.389. .943.4390!430 #:3/..3/800..

.90.79!430 4:.. 389.42504:7 5747.2..10894!430:83!43074807/024 #:3%0723. %03389. 08 .250 08 .5. 47089.0/./.3/:80....79:.-4.70809. 389..%0723.30 -7.08 ..4250794.0 ...42507  84 389.2 470...3:54..

:87.

-.

.79 ..8810..8:8:.247!430 ...7789..!747..!747. 4:.789..79088   .247!430 . ...37:390.

' 995.

.

 2.2 47.

4.07.0.

3. '97.9431742 %94'-90...90/-9017439 03/ .79088   .8 .3/97..344088:.:2039 %8.9438.903.943.0 94.381472..9  .38.94341.55.47 %.0 !430.425.8$% ":07 ..3/ !..55.94341' -.4/0 .425.55.0/90.425.943894.759849.2894 -0..80/ 5747.5747.482.8810 47..28:83.$.3 /4.55.9.9438947:34390!430 .94383...705488-0 7488 ..9..9438 7488 ./...990.38.35:.943413/74/..74:8 97.37:3.. %00..80/4390 /4..3-74807 7488 .-0 94..908.70.:20390307.:9.

' .79088   .

' .79088   .

.9  *990 809%09 0447/  *990 80903907847439.9  3/4 47/077439 98  3/4 2.3'0 .0 *990  < < .9  &3/43/430&3/4 70..943  5:-.79088   .7/.00 98  3/4 *809//03 1. 25479 47 2.9&.9 473  70.3'030&'0 70.. 97:0  2.80  70.9  3/4 809439039'0 2..88 0447/ 0903/8&55.55.2 5430  5:-.3'0  &%09.943439039#0..-0*99030 &%09.4/.700355.:3.970..-0 70.9 473    &'02...0447/3.//$:-.9433  #0.943/38..70 1:$.3 $491.

0*990( <03/ .2070.79088   .9 473   &'0 2.701:$.4/ ..:3.943 3 #0.970.9 473 70..943439039#0.943/38.943 3 03/ 2502039.55.00801( 3/4*809//031..970.943/38.:3.4..700355.(3997.4.0447/3 -0.3'0.9( 3/4809439039'02..9( &3/4 3/4&3/4.0 39071.55...//$:-.2070.3'0&'0.0 0447/&55.9&.-0.(399439039#0.80( 70.9.3 $491.-0 *990&%09.3'0( &%09.7/.943 .97:0( 2.(3997.943 0447/ .4/ .3 $491.9( 3/447/077439801( 3/42.9( *990809%090447/( *99080903907847439.4.

42530447/ .9.7488..7488 .425078384:7.0  %0.014/0787..94 -0.

580  ..422..2.9090'147 0447/ :80901443 .2.3 %40307.2.3/30459438 :3/07.2 .0*4.43840 4785.88 47 2.2<.

-3.

47.

2.2.

9089.

5430.

2<.88 %4. 4785. 0447/ .7488 .9.0*4.43840 4-..425090'94 -0.2.0 :80 ..

-3.

47.

2.2.

9089.

5430.

9.0*4. 4785.. 0447/ .88 %479090 -0.2<.2.10 :80 4:9925 4-.0 84:7.4/094..0.

-3.

47.

2.2.

9089.

5430.

9094108 4785.2.4:8. 0447/ .422..0*4.3/0307..88 %0570.2<.

925.

0447/  4785.0*4..2<.2.

925.

0447/ 2 .79088   .

4250.2<.3/7:30447/ %50 2..2.0*4.0 34785.

0849.3/..55.7/ %0570..74343.79088   .4:8..422..:7080 39490!430 47- :83.925 %50 2...088.79390$5734.$5734.90723.9434390!430 #089.8:59030 0447/  .55.943 .7/ 830.3 -0.0/054 390!430 950 .995.42580/-090788 3 80.

79088   .78 .3/ 14734 ":089438 #02.

Sign up to vote on this title
UsefulNot useful