Apples iOS4 update What’s in it for the developers

Last week at Apples World Wide Developer Conference Steve Jobs unveiled iPhone OS’s yearly major upgrade, introducing a plethora of new functionality. In this post we will try to touch the tip of iceberg in terms of what iOS4 has to offer to the developers.

The first thing you’ll notice about iPhoneOS is that it has been renamed to iOS basically because now it runs on iPads, iPhones & iPod touches & iOS is somewhat a generic name.

Below is the description of new features in the iOS from the developer’s point of view.


The first and foremost thing that catches the attention of developers is the ability of iOS4 to multitask. Multitasking is not a new feature in mobile computing, Palm’s WebOS, Google’s Android & even Microsoft’s Windows Mobile have multi-tasking capabilities. Multitasking application lifecycle is a little different than the traditional application lifecycle that we were used to in Cocoa touch. Apples multitasking implementation is somewhat similar to that of Google’s on the Android platform. Which is in-fact not true multitasking just a mere illusion of multitasking.

When the user wants to switch to another application the state of application is saved or frozen in the memory and when the user gets back to the application the state of application is restored giving an illusion that application was running all along.

When the application is inactive it is barred from any processing except if the application has registered as one of the following

  • Location (GPS related)
  • Audio
  • VoIP (Voice over IP)

This is how application state is specified in the UIApplication.h header file

typedef enum {




} UIApplicationState;

Illustrating that we have three application states on the iOS4.

  • Active
  • Inactive
  • In Background

When the application is launched we will receive the usual message from the app delegate

- (void)applicationDidFinishLaunching:(UIApplication *)application

didfinishLaunchingWithOptions(NSDictionary *)launchOptions

In addition to this we will now also receive this message

-   (void)applicationDidBecomeActive:(UIApplication *)application

When going to the background we will receive these messages

- (void)applicationWillResignActive:(UIApplication *)application

- (void)applicationDidEnterBackground:(UIApplication *)application

When in background there are no guarantees that the app will remain in the memory for the entire eternity. If there is a OOM(Out Of Memory) call the runtime will kill our application & free some memory.

When our application comes back to foreground these two methods will be called by the app delegate.

- (void)applicationWillEnterForeground:(UIApplication *)application

- (void)applicationDidBecomeActive:(UIApplication *)application

We can implement our logic in these two delegates; like connecting to the server again or whatever the logic of our application demands.

iOS4 also gives us the functionality to ask for a little more time for processing when the application is being suspended so that we can save state or finish the job for that matter before getting suspended. These are the two calls we can use to tailor our app to our requirements.

-   (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler: (void(^)(void))handler;

-   (void)endBackgroundTask:(UIBackgroundTaskIdentifier)identifier;

*Notice the weird looking syntax (void(^)(void)), this is known as a block & is a recent addition to the C, C++, Objective C & objective C++ by Apple & is abundantly used in many Foundation classes so understanding it is very crucial, more on it later.

Local Notifications

A new feature in iOS4 is of local notification system, this feature somewhat mimics the Apples Push Notification System but is local to the device. Any application can register for notifications locally on the device & the device can then send periodic updates as specified or can change the application badge or do all of the stuff that was possible with Push Notification System. For more information on Local Notification be sure to check out the UILocalNotification.h header file.


UIAutomation is a new framework that Apple has introduced with the iOS4 SDK. Now you can write Javascript based scripts to automate user testing & check your application rigorously. You can run your scripts along with all the performance tracking systems included in the SDK like Instruments or Shark.

Event Kit

Enables the developers to access the calendar of the user on the device, so that the developer can create, edit, remove & search events on the calendar locally & or any online calendars users are using. Developers will also be able to record change notifications for the events on the calendar.


iAd is Apples advertising framework, developers can use iAds for loading & presenting ads. Apple also enables developers to respond to the events in ads. One plus point of iAd is that when you tap on the ad in the application, the application will not exit to show you the ad in Safari, you will remain in the application & you can close the ad anytime you want. This is one big convenience when compared with other ad offering frameworks like Google’s Ad-Mob.

Game Center

Is a social networking gamming system something like OpenFeint. Now you can view achievements, compare them with your friends, view leader boards, find new games etc all of the stuff which you were able to do with OpenFeint is now possible with Game Center.

Core Motion

In addition to the accelerometer Apple has added the gyroscope to the iPhone 4. Now you can use the API in the Core Motion to take advantage of gyroscope & make your applications more interactive.

Core Foundation & Foundation additions

CF & NSFoundation has been brought to the snow leopard equivalence in iOS4, which includes the inclusion of Blocks & Regular Expressions to name a few.


Here is a small introduction to Blocks to get your feet wet.

Blocks are self-contained units of work; they are similar to but far more powerful than traditional function pointers. Blocks are objects & they respond to NSObject methods. Here is a small example on blocks to get you started:-

Declaring a block variable:

void (^my_block)(void)); //first void is return type (^my_block) is the block declaration & the other void is the argument in the argument list.
Assigning a block object to it:

my_block = ^(void){ printf("hello world\n"); };
Invoking it:

my_block(); // prints “hello world\n”
Accepting a block as an argument:

- (void)doSomething:(void (^)(void))block;
Using that method with an inline block:

[obj doSomeThing:^(void){ printf(“block was called”); }];

Developing iPhone applications on Linux.


As we all know that Apple has limited the native application development of iPhone/Cocoa touch to only the MAC OS X & its IDE Xcode, which consequently leave out a huge number of developers out of the thrill. In this tutorial/article we will try to explore how we can use our beloved Linux machine to develop applications for iPhone/Cocoa touch platform.

We will follow a step by step tutorial to install tool-chain for the iPhone/Cocoa Touch and in the end I will also provide elaboration on how to use our very own Eclipse IDE for code editing features for objective C.

Basic Linux acquaintance and a know how of C language is a pre-requisite.

You will be needing an iPhone, a Linux machine, a wifi connection & a little patience to get it done but I can guarantee you once you have done it you would feel like King Arthur, assuming he always felt good.

I will be using Ubuntu 9.04 Jaunty for the sake of our example.

Jail Breaking

At its core MAC OS X is based on Darwin which integrates a couple of fascinating technologies, most importantly XNU kernel a Mach 3.0 based microkernel and operating-system services based on 4.4BSD (Berkeley Software Distribution). Darwin forms the core set of components upon which Mac OS X and iPhone OS are based.

Being basically unix in nature Apple employed a popular UNIX technique known as “chroot” to restrict the access of processes to an isolated subset of the file system.

Wikipedia links for the above jargon if you are interested are highlighted below, as I would not go into the irrelevant lengthy details but will give you pointers where the need arises.

The first thing you will need to do is to jail break your iPhone. Jail breaking your iPhone wont break your iPhone it will just set your phone free from the restrictions Apple has applied on it, let your phone breahthe in some fresh air. There are a lot of tutorials and softwares available to do this so I wont waste my time on this too, just google it and you will be on the right grounds for sure.

You can even search in youtube and will find video tutorials on how to break the chains of your phone.

QuickPwn, XPwn, Pwnage, and WinPwn; are just a few keywords to make your life a little easier & a little better.

Don’t scroll down if you haven’t Jail broken your iPhone yet. If you are having trouble jail breaking your iPhone just drop me a line below in comments I would be eager to help you out.

Post Jail Break

There are a few softwares we need to install on the iPhone to get our work done. Depending upon the method/software used you will have an installer or a Cydia icon on your springboard(that is the desktop of your iPhone if in case you are wondering what SpringBoard is).

Cydia & installer Icons
Cydia & installer Icons

Search and download the following softwares from either cydia or installer from your iPhone.

OpenSSH secure remote shell client and server(openssh) :enables you to transfer your programs to the iPhone and log in to execute commands on the device

The Linker Identity Editor(ldid): sign your code with a bogus key to make the iPhone run it & the Respring(respring) utility to restart the dashboard.

You can use the keywords in the brackets for search.

Once you have installed ssh open terminal app(Goto Applications on the top right corner of your screen → Accessories → Terminal) & type ssh root@[ip address of iphone], terminal will prompt you to enter roots password type alpine which is the default password for the root. Now type passwd and hit enter to change the default password and secure your iPhone. Do the same procedure for the username mobile which also have the default password alpine.

Note you can see the ip address for your iphone using the Settings application on your iphone and going to WiFi.

Installing the tool-chain

Tool-chain can be installed in two ways, one way which we will discuss further is by downloading the source and compiling the source of the tool-chain and if you don’t want to get into the hassle I will provide my pre-compiled version of tool chain so that you can use it off shelf.

Note tool chain refers to compilers, assemblers, linkers, and other tools that work together to build an executable file for a particular platform; if in case you are wondering what tool chain is.

Installing tool-chain from the source

One advantage you will get from downloading and installing from the source is that you will get the latest build for the tool-chain available.

The iPhone tool chain used by Apple for its iPhone SDK is actually based on the open source GCC — the same tool chain used in Linux, Unix & its variants & which off course is open source.

Because of its open source origins, the base source code for the iPhone SDK is available to anyone under GPL.

The following software’s are necessary to build tool chain on Linux: bison, flex, build-essentials, and autoconf packages. You can use the following command to download and install the programs from the repositories.

The process to download and compile tool chain from the source is explained on the web page, If you have any problems or errors while following steps read the comments below and if it still doesn’t suffice leave me a comment I will try to help if possible.

Get a copy of the iPhone root file system, make sure your iPhone and linux box both are connected to the same WiFi network, go to networks double click on the iphone device provide user-name and passwords for authentication and then download these two directories /System/Library/Frameworks/ and /user/lib to your /usr/local directory.

Download the tool chain code from the link

extract the .tar file with any file archiving utility of your choice and then run the following command
cd ~/iphone-2.0-toolchain


It will take a while and a lot of text would whiz by your screen and after a while if all went right you would get your prompt back.

Congratulations! you have installed your tool-chain for iPhone on Linux.

Now open a text editor or any IDE e.g eclipse or netbeans whatever you like

Continue reading “Developing iPhone applications on Linux.”