Sunday, July 26, 2009

Chapter 5 - What iPhone Application Development lack

When compared to desktop application development, iPhone application development lacks some of the features. We are going to discuss these features here

Limitation on Network Infrastructure

iPhone is an always connected mobile device that uses another company’s wireless infrastructure. So apple place some restrictions on iPhone developers than Mac developers (apple developers has all freedom for developing and distributing application without the approval from Apple). The restriction is only for minimize the chance of programs degrading the performance of the shared network

Only one running application is possible

On an iPhone, only one application can be running at a time. This is because of limited memory and processor speed. This may change in future as iPhone gets more memory and powerful processor

Limited Access to the system resources

Desktop application can access everything in the system. But iPhone restricts the things that our application can get. iPhone application can only read and write files from iPhone’s file system that was created for our application. This area is called iPhone Sandbox. Here our application store documents, preferences and other data.

Only one window is possible at a time

Desktop application can display any number of windows at a time. But iPhone application work with only one window at a time

Application window size restriction

Size of the iPhone application window is limited to the size iPhone screen

Port access restriction

iPhone application can not access low number network port

Limited Response Time

iPhone has limited response time. When your program is launched, you have to get your application open, preferences and data loaded, and the main view shown does not take more than a few seconds. At any time, when your program is running if the user presses the home button, iPhone goes home and you have to quickly save everything and quit. If you take longer than five seconds to save the data, the application process will be killed.

Limited Screen Size

iPhone screen is just 480 * 320 pixels. So we have less room to work with than on modern computer.

Limited System Resources

The current version of iPhone has 128 MB or 256 MB of Physical RAM. Half of the memory is used for screen buffer and other system process. Half of the memory is available for our application. Cocoa touch has a built in mechanism for letting our application know the memory is low and then your application must free up un needed memory or risk being forced to quit

Energy limits

For mobile platforms, you have energy (battery) limitations. When run some programs ,it produces high levels of waste heat that the phone becomes hot to the touch and the battery quickly runs down. The Camera application is an example.

But iPhone SDK features help you to design your applications to limit CPU use and avoid running down the battery.

Missing Tools

iPhone misses some of the most important functionalities available in MAC. iPhone SDK does not support Core Data and Cocoa Buildings. Cocoa Touch does not support garbage collection
Many frameworks like Core animation is partly implemented.

Missing Keyboard and Mouse

iPhone doesn’t have mouse and keyboard. User interaction with program is different. Most of the interaction is handled by iPhone. If we add text field, iPhone automatically brings up a keyboard when user clicks on the text field

Some new features

iPhone SDK contains some new features that is not available in Cocoa. iPhone SDK provides a way to determine the phone’s current geographic coordinate using Core Location. iPhone has a built in camera and photo library. SDK provides a way to access these. iPhone also has a built-in accelerometer that allow us to detect whether the phone is being held and moved

These are the main limitation of the iPhone and its development. There may be some other limitations. If you are aware of any of the limitations other than these, please send to me or add a comment

Chapter 4 – iPhone and iPod Touch – An Introduction

The iPhone is built on Apple’s OS X, which is itself built on top of UNIX. Xcode, the same development environment that’s used to write code for the Macintosh, is the core of native programming for the device. Putting all these features together provide a mature development and runtime environment.

Here we are going to discuss about some history about iPhone and iPod Touch, its technology, specifications, etc.

History
In 2001, Apple introduced iPod to the world. The iPod was a masterpiece of portable design. It highlighted a simple and beautiful interface, giving users access to thousands of songs that they could carry with them all the time.

In 2006, Apple came up with a next major device – an iPod like mobile phone. That would be called iPhone. Because of its technology and superb user design, the iPhone offered a new hope to the world. It promised a new feel to the cellular phone industry. Apple released their first version of iPhone on June 29, 2007. People were very much interested in iPhone. Apple sold 270,000 iPhones in two days and topped a million units in just 1.5 months.. After the initial release, interest in the iPhone continues to grow. On July 11, 2008, Apple released new 3G iPhone and its public deployment of the iPhone software development kit (SDK). Higher numbers of iPhone sales predicted for 2009 and beyond. The 3G managed to hit a million units sold in just three days.

Apple today revealed their latest mobile phone, the iPhone 3GS. Here S stands for Speed.

iPhone 3GS
The iPhone 3GS is available from June 19th in North America and Europe. Today it is availble in various parts of the world.

The 16GB version is available for $199, and the 32GB version is $299.

All models are available over on the Apple Store

iPhone 3GS looks virtually the same as the iPhone 3G. But the 3GS offers increasing application speed, battery life, camera resolution, memory and more. According to Apple, the faster processor in the 3GS increases launch times of popular apps from 2.1x (launching messaging), to 3.6x (opening an Excel spreadsheet).

3GS has brand new 3-megapixel camera, with auto-focus, auto-exposure, auto-white balance, low light and an auto-macro mode. It can capture still images as close as 10cm away. The camera can also capture video at VGA resolution (yawn) at up to 30fps.

3GS also provide improved graphical performance. The iPhone 3GS also supports 7.2Mbps HSDPA wireless connections. In addition to these, 3GS adds several new features not supported on the 3G. Battery life is also improved.

It has a new voice control mode. It allows voice-dial, tracks to play in iTunes, open web pages, and control other applications.

The iPhone 3GS takes advantage of all of the features of the iPhone 3.0 OS. It includes cut-copy-paste, landscape keyboard, app store micro transactions, MMS messaging, stereo Bluetooth and much more.

Comparison chart for various versions of iPhone

iPod TouchAfter the release of the original iPhone, Apple updated their iPod series with the iPod Touch (after some months - 2007). This was a new iPod version built on iPhone technology.

Like the iPhone, it uses a 480x320 multi-touch screen and supports a mobile Safari.
iPod Touch didn’t have any other telephonic capabilities and camera.

On 2008, Apple released new version of the iPod Touch. It included an external speaker and volume controls. It has no cellular connectivity. So iPod Touch can only access the internet through local-area wireless connections.

iPhone Vs iPod Touch

Here I am trying to figure out the difference between iPhone and the iPod Touch. The iPhone has a few extra features over the iPod Touch. It has a telephone, bluetooth, a digital camera and the battery lasts slightly longer.

The price difference between an 8GB iPhone and an 8GB iPod Touch is also just $100.

Now the downside is that the iPhone needs to be unlocked to work in some countries.

A comparison chart of iPhone and iPod is given below

Both devices are almost similar. So making the choice can be tough. In an effort to help those considering an iPhone vs. iPod touch, the chart above allows you to compare the devices head to head.

Luckily, they are both great. So whichever you choose, you won’t be worry

iPhone input and output
The iPhone’s input is handled through a multi-touch-capable capacitive touch screen.
There is no need for other tool. A user can taps on the screen with one or more fingers.

The iPhone’s visual output is centered on a 3.5” 480x320-pixel screen. This screen is larger than most cell phones to date. The iPhone can display either in portrait or landscape mode. That means that it can display either a 480-pixel-wide or a 480-pixel-tall screen.

The iPhone’s output supports a variety of media. It support music and videos in a number of formats—including AAC (Advanced Audio Coding), AIFF (Audio Interchange File Format), Apple Lossless, Audible, MP3, and WAV, MPEG4 videos. An iPhone delivers CD-quality audio and high frame rate video.

Users will load most of their audio and video from their computer, the iPhone can play streams at high speed over wi-fi on a good network.

iPhone network connectivity

iPhone support two types of wireless network connectivity – local area and wide area.

iPhone normally prefer network connectivity through local area wireless network. It can use any nearby wi-fi network. This can provide local connections at high speeds of up to 54 megabits per second (Mbit/s), thus making a network’s link to the internet the most likely source of speed limits, not the iPhone itself. Password and other details are saved in iPhone and so it can automatically reconnect to a known network whenever it can.

The original iPhone uses the EDGE network for wide-area wireless connectivity, whenever local-area wireless access isn’t available.

The 3G iPhone and 3Gs iPhone supports the third-generation of mobile phone standards.

If you are working in a corporate environment where everyone will be accessing your application through a companywide wi-fi.

iPhone browser
The iPhone’s browser is a mobile version of Apple’s Safari. It’s a full-fledged desktop browser with access to DOM, CSS, and JavaScript.

iPhone Hardware features

The iPhone includes all of the cell phone standards, but also some neat new elements such as accelerometer, bluetooth, camera and GPS

Accelerometer

The accelerometer is used to detect the orientation change with relation to gravity. That is accelerometer sense when the iPhone is rotated from portrait to landscape mode or back. They can also be used to approximately map an iPhone’s movement through three-dimensional space.
The iPhone contains three accelerometers.

Bluetooth

The iPhone uses the Bluetooth 2.0+EDR (Enhanced Data Rate) protocol. Bluetooth is a protocol that allows modern cell phones to access wireless devices.

Camera

This is another requirement for a modern cell phone. The iPhone’s camera is 2.0 megapixel.

GPS

The older versions of iPhone don’t support real GPS. But 3G and 3GS iPhone includes a true Assisted GPS (A-GPS), which supplements normal GPS service with cell network information. They can access GPS functionalities through the iPhone SDK.

Chapter 3 - Steps for iPhone development – A Summary

The steps involved in developing an iPhone application is
  1. Get an Intel based Mac computer running Leopard (MAC OS X 10.5.3 or later).
  2. sign up with Apple’s site to become a registered iPhone developer.
  3. Download iPhone SDK from Apple’s site and install iPhone SDK and tools in your Mac machine.
  4. Learn Objective C programming languages.
  5. Study how to use Xcode IDE and Interface builder.
  6. Write a program using the above tools
  7. Sign-up as an official developer. If you plan on releasing your program, you will need to sign up with the iPhone Developer Program. The Standard cost is $99. You need to agree to Apple's terms and conditions, and sign and return the contract. To test your code on an actual iPhone, you need to sign up. Once you're on the Developer Program Apple send a certificate. It allows you to pair up with an iPhone device.
  8. If you are ready with your finished application, you can submit it to App Store. It involves process of zipping up the file, uploading it with a description, a large and small icon, and screenshots. If everything is correct, then it usually takes Apple a week to approve the content and it finds itself in the store

Saturday, July 25, 2009

Chapter 2 – iPhone SDK – An Introduction

Are you ready to start iPhone programming ? Are you ready with your Intel based Mac Machine? Then you need Apple’s iPhone Software Development Kit (iPhone SDK). This is free and is available to the members of Apple’s Developer Program.

iPhone SDK include Xccode (IDE) and iPhone Simulator along with lots of other tools.
Xcode is Apple’s Integrated IDE and we can use it for creating, debugging, compiling and performance tuning application. Simulator allows us to run iPhone application on Mac

Latest version of iPhone SDK is iPhone SDK 3.0.This release includes bug fixes and usability enhancements, including a more accurate iPhone Simulator

Downloading iPhone SDK

You can download iPhone SDK from Apple’s site at http://developer.apple.com/iphone. The steps involved in downloading iPhone SDK from this site is explained in my first blog (Chapter 1 - Beginning Your iPhone Programming Today - An Introduction).

Before download the iPhone SDK file, it will ask your Apple ID. If you don't have the Apple ID, just click the “Create Apple ID” button and fill your details in the form. Apple will send an email to your Email ID which is given by you during the registration. They send a confirmation mail and also give the link for downloading the SDK.

iPhone SDK installation is a file with extension .dmg. When I downloaded iPhone SDK, the file name was “iphone_sdk_3.0__leopard__9m2736__final.dmg”. It may vary

Pre-Requisite

iPhone SDK requires an Intel-based Mac running Mac OS X Leopard version 10.5.7 or later. . The file size is around 2134 MB.

Installing iPhone SDK in your Mac Machine

The steps involved for installing iPhone SDK is explained here

  1. After downloading iPhone SDK to your Mac machine, double click on the file with extension .dmg extension. This will display a window like this

  2. Please Select iPhone SDK icon in this window and double click on it. For now discard other icons displayed in that window. Then we will get the following window
  3. Click Continue to continue the installation. This will display a window looks like the below one
  4. From the above screen, you can select required tools using “Custom Install”. Now please select the options shown in the above figure and then click Continue button. This will display a window like the on shown in the following figure
  5. From this window, you can change the installation location for installing the SDK or we can install SDK in the default location. The default installation location for iPhone SDK installation is /Developer. After this click Install to start the installation

  6. During the installation, we need to enter Mac Username and Password (as shown in the above figure)
  7. After validating the entered information (Username and Password), the installation process will start. The installation progress is shown in a window. This window looks like

  8. If there is no interrupt, the installation will succeed and we will get a window like

Now iPhone SDK installation is completed and you can clsoe the window

Tools

The most important tools comes with iPhone SDK are Simulator, Xcode, Interface Builder, Instruments and Dashcode. The following section give a small introduction to these tools

Simulator

iPhone SDK includes a simulator that will allow you to run your iPhone application on Mac. This enables you to create and test applications on your desktop. Simulator does not support hardware dependent features such as camera. But this is helpful for iPhone development and studying.. You can do this without connecting to an actual iPhone or iPod touch. The Simulator offers the same API used on the iPhone and provides a preview of how your concept designs will look

Xcode

Xcode is Apple’s Integrated IDE and we can use it for creating, debugging, compiling and performance tuning application. It is the most important tool in the iPhone development. It provides a project development and management environment. It includes source editing, documentation, and a graphical debugger. It is built around several open source GNU tools, namely gcc (compiler) and gdb (debugger). The complete Mac OS X developer tools chain is distributed as part of Xcode .These tools include Interface Builder, Dashcode, Instruments and the WebObjects framework

Interface Builder

Interface Builder is Apple's graphical editor for designing user interface components. Developers can use IB to create user interfaces by dragging user interface elements such as buttons, labels or text fields from a palette of predefined controls and dropping them into the window or view. Interface Builder works with Xcode.

Instruments

Instruments are the tool used for tracking memory leaks and making sure your applications run efficiently without any problem on iPhone and iPod Touch. It includes graphical time based performance plots that show where your applications are using the most resources. It shows memory usage and monitors performance. As a developer, this helps you to identify the problem areas in your applications. It is build around the open source DTrace package (developed by Sun Microsystems)

Dashcode

Dashcode allow you to create Web applications (web widgets) that you can run outside of a browser environment (safari).

For now this explanation is enough. We will discuss more about each and every tool in coming chapters.

Chapter 1 - Beginning Your iPhone Programming Today - An Introduction

Welcome to the iPhone Programming world
So, you are going to write iPhone programs? Welcome to the most interesting world of programming. Today, iPhone is one of the most interesting programming platforms. Apple’s iPhone is more than just a new programming platform; it’s an entirely new way to think about mobile technologies.

Here I am going to explain each and every point of iPhone programming. This is my first blog which includes only the basic details of iPhone

This chapter is intended for novice programmers and experienced programmers can skip this chapter.

Things we need before writing iPhone programs

Before writing iPhone programs you need to setup the following things
  1. You need an Intel–based Macintosh running Leopard (MAC OS X 10.5.3 or later).We need to use a Macintosh computer released since 2006. It can be a laptop or desktop. You can buy a Mac Mini or MacBook
  2. You need to sign up with Apple site to become a registered iPhone developer
  3. You need to download and install iPhone SDK from Apple’s site
  4. For distributing application in app store, we need to purchase one of the developer programs. Then apple will send the necessary information to you.
Hardware requirements for iPhone program development

IPhone program development has minimum hardware requirements .Without this requirements, iPhone programming cannot begin. Here we describe essential hardware needed for iPhone development.

Mac machine
We need an Intel-baBoldsed Mac machine or Mac Book because iPhone applications can only be developed using Apple X OS. A non-Intel based Mac machine cannot be used for iPhone application development. We can choose between a Mac Book (or Mac Mini) and a Mac PC. Please make sure that it has at least 2GB RAM for smooth performance
We can use an alternative as a Power PC Mac for iPhone development. But the output will result in extremely low productivity. If you still want to use PowerPC make sure it is running Leopard 10.5.4 or higher

iPhone
Phone applications can be developed using the iPhone Simulator (that comes bundled with the iPhone SDK) or iPhone. But iPhone Simulator does not support system dependent functionalities like GPS functionality or access the internet from within the application. In such cases the iPhone simulator is not enough and you need to buy an iPhone.
Once you have this minimum hardware ready, you can start to write iPhone applications and games.
Signup as a registered iPhone developer

For downloading the iPhone SDK from Apple, we need to register as a registered iPhone developer. Steps involved are
  1. To sign up, please visit http://developer.apple.com/iphone
    This will show a page similar to the one shown below (Here I am using Internet explorer as browser from Windows. You can choose to use Apple Safari as browser from MAC

  2. Then click on the Register link at the top right (marked with red circle). This bring up a page similar to shown below

  3. Then click on the continue button (marked in red circle). Then we will get the following page

  4. Select the first option (Create an Apple ID) and click continue.


  5. Enter Apple ID and other account information in this page and click continue. Next page is

  6. Select your options and click Continue. Then you will get the screen

  7. Here you need accept the iPhone Developer Agreement and click I Agree.

  8. Then Apple will send a verification code to your email id. You need to copy the verification code from email and paste that code to the edit box in the following screen and click Continue

  9. If the verification code is correct, you will become a registered iPhone developer
  10. Then you can download lots of tools from apple site including iPhone SDK
Downloading iPhone SDK
To download iPhone SDK from Apple site, we need to get valid Apple ID. Once you register with Apple, follow the steps given below

  1. Visit the site http://developer.apple.com/iphone and click iPhone SDK link (as shown in the figure in red circle)

  2. Then you will get the following page
  3. Click the Downloads link

  4. This will download iPhone SDK installation to our machine
  5. We can also download documentation, video, sample codes, etc. from this site.

    We will explain more about iPhone SDK and its installation in my next tutorial (in Chapter 2).

Distributing application in app store

We can not distribute our application to apple store without the permission from Apple. If you plan on releasing your masterpiece at any point, you'll need to sign up with the iPhone Developer Program. There are two types of programs are available.

  1. Standard program - The cost is $99, and it involves agreeing to Apple's terms and conditions, and signing and returning the contract. If you complete the project, you will need to sign up in order to test your code on an actual iPhone rather than iPhone simulator. Once you are on the Developer Program you are sent a certficate, which allows you to pair up with an iPhone device. It provides development tools, resources, technical support, and distribution of our application via App Store, the ability to test and debug our code on iPhone.
  2. Enterprise program – The cost is $299. It is for companies developing proprietary in-house application for iPhone/iPod

    We will discuss more about these in the coming chapters