Getting Started with iPhone Development
Join the DZone community and get the full member experience.Join For Free
I know that it’s been quite a long while that I haven’t written anything on this blog and it marks a record in my blogging history. Moving from a country to another and starting a new life specifically as a graduate student has its own difficulties that eat all your time.
However, the good news is that now I have some obligations to blog at least once a week until the end of this semester and it gives me a good chance to return to blogging covering new topics that may not be very related to the .NET world!
For this semester I’ve taken a graduate Software Engineering course with Dr. Macneil Shonle (recently, we’ve been finding many clones of Scott Hanselman!) and as a main part of our duties for this course, we’re supposed to work on a software project as a team.
The software project for this course is something that should run on top of the iPhone/iPod Touch platform and we need to form groups of 4-5 people. We’re supposed to collaborate on this project and deliver it in a timely manner (by the end of the semester) and follow an incremental approach to build a useful application. Besides, we’re supposed to prepare documentation and information about our work individually and specifically blog about our experiences on a regular basis. Surely, this is good news for my blog readers.
Apparently, Dr. Shonle had some goals in mind by defining this task for us:
- Force students to work as a team and learn about all the team-work concepts
- Help them learn about new platforms and technologies especially with a funny project for the iPhone platform
- Contribute something to the community by building new applications.
- Learning Software Engineering concepts and applying them in a real-world project in action.
Therefore, I’m going to publish some blog posts in the next three months on this blog and cross-post them to our internal Moodle blog to get some points! I try to share my experiences, opinions and the challenges that I face with, so my readers can grasp an understanding of the process of programming with the iPhone/iPod Touch platform.
To be honest, I’m not a big fan of Apple and haven’t used their products that much, and I’m not planning to do that for ages. I know that there are many people who find their products exciting but as a matter of a fact, I see no point in what they do except one thing: improving the user experience. As a technical user, this is not a big deal for me. As I’ll point in a moment, I got some bad impressions from my first experience with Apple product development.
iPhone Operating System
The iPhone Operating System has derived many features from the Mac OS X and of course, has altered many of them or has introduced new features appropriate for a mobile device, so those who have written programs for the Macintosh operating system should have an easier job learning the process of building an application for the iPhone platform.
The iPhone operating system can be considered as a hierarchical multi-level stack of technologies included in a single platform. This consists of four main layers from bottom to top:
- Core OS
- Core Services
- Cocoa Touch
The first two levels are fundamental layers that provide more basic functionalities and features, services, and interfaces such as APIs to work with files, low-level data types, network sockets, etc. These programming interfaces are mostly provided in C programming language.
The third level, media, provides several APIs to work with graphics, audio, and video, and combines C and Objective-C languages in its interfaces.
Finally, the upper level, Cocoa Touch, which is basically the main layer that programmers deal with is a higher level API provided in Objective-C to let you apply many of the common tasks in your code.
Typically, an iPhone application is written on top of the Cocoa Touch layer but if you can’t find relevant APIs for your work, you may dig deeper and use APIs from the lower layers.
Software Development Technologies
Building an application for the iPhone platform can be done using several approaches. The default approach, as many of you already know, is applying Objective-C and other development tools provided by Apple. This is used by most of the applications written and released on AppStore.
But the other approach that may be familiar to the fellow .NET developers is MonoTouch, a technology released as a part of the Mono project to let .NET developers apply their knowledge in the .NET development to build applications for the iPhone platform. Basically, MonoTouch binds .NET APIs to native APIs that I described above. It also has a good integration with Xcode IDE that I’ll describe later in this post.
Unfortunately, MonoTouch is a commercial product and despite our interest to use it for our project, the pricing wasn’t fair for our educational purposes so we ended up with the default approach (using Objective-C).
Objective-C is a reflective and Object-Orientated derivation of the C programming language that adds a messaging style to the C language.
Objective-C is mostly known for its wide usage in Apple Mac OS X and iPhone development. If you’re going to develop for Apple products, you definitely need to know this language in a very good level.
Knowing the C programming language and being familiar with the Object-Oriented concepts, you have a straightforward way to learn Objective-C syntax and style of programming.
Apple developer guide has a good introduction to this language that can give you a basic idea of the language.
The development process of an application for the iPhone platform is very similar to programming for many other mobile platforms like Windows Mobile or Android, but some legal phases to get permissions from Apple add to its complexity that in my opinion seem to be a very annoying part of development process for iPhone platform.
Following some steps, you need to sign up on Apple website and submit your generated local certificates to get a Provisioning Profile (after getting approved by Apple) to use on your machine.
As an academic project, we have access to Apple University Program and had an easier process to get our profiles approved here. We have received a set of iPod Touch devices from the university to use for this project and test our code.
After having the Provisioning Profile, and registering your devices on the Apple website, you can start building applications using the below-mentioned tools. After building your applications, you can test them on a local emulator, and then you can deploy this application to your device as well.
Here is a simple example that can get you started with the programming style for the iPhone platform.
Another major limitation of development for the iPhone platform is that it mandates you to use a real Mac machine to write your code and deploy them to your devices. So whether you use the default technologies or MonoTouch, you need to run everything on a Mac machine (and you can’t use a Virtual Machine neither).
Having this important requirement, you can use a rich set of development tools provided for the iPhone development. The most common IDE to use for Mac OS X and iPhone development is Xcode.
You can also use the Interface Builder to put a rich set of controls and user interface elements for Cocoa on your application surface.
Here you can see a good description of the main development tools you can use for iPhone development.
Published at DZone with permission of Keyvan Nayyeri. See the original article here.
Opinions expressed by DZone contributors are their own.