{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
Creation of First iPhone application explained
Summary
This article explains the creation of an iPhone application. Screenshots included. Goes through choosing a template to base the iPhone application on. Proceeds to explaining the basic contents of the project and compiling and running it.
 
Table of Contents

Creating a new iPhone project

Using a Template for the iPhone application

Figure 1. iPhone New Project Template Dialog Box. The iPhone OS has a smaller set of templates compared to building applications for Mac OS X.

A Navigation-Based Application

Figure 2. First iPhone Application. By default this project and its content are saved into the Documents folder (which, of course, can be changed)

The Project Window

Figure 3. The project window. It contains a navigation section of Groups and Files on the left, a detail window at the top and a code / editor window at the bottom.

Compiling the iPhone Application

Figure 4. The compiled iPhone application in the simulator. This is a Navigation Based Application; hence it has a navigation bar at the top and a TableView. Since no data has been added, this view is empty.

Figure 5. The default icon for iPhone First App is in the main screen of iPhone. Since no special icon is made for this application, an empty/default white icon is shown.

 
Article Series
Previous Article:
Test Your Knowledge: Summary of various tools installed with iPhone SDK
This article is part of the Series:
Article Series: Getting started with iPhone development
Next Article:
Test Your Knowledge: Creation of First iPhone application explained

Creating a new iPhone project

Xcode is the development tool for creating iPhone applications. It is also used to creating applications for Mac OS X operating system. Once you installed the Xcode tools, you can run it from Developer\Applications folder (default location for installation); or, you can drag it on to the dock for quick use.

Xcode is like Visual Studio and Eclipse, if you are used to developing with those tools. Visual Studio is used for developing applications for Windows, Web, etc. The primary programming languages there are C#, VB.NET and C++. And, you would use Eclipse primarily as a development environment for Java programming language (though, it is used for a whole lot of other languages and tasks).

So, in summary, you would use these three development tools for developing applications for three different phones:

  • iPhone -- Xcode Tools
  • Android -- Eclipse
  • Windows Mobile -- Visual Studio

Using a Template for the iPhone application

By using templates for a project, you can create a certain type of iPhone application quickly. From the Xcode menu, choose File - New Project to open the New Project templates window.

Figure 1. iPhone New Project Template Dialog Box. The iPhone OS has a smaller set of templates compared to building applications for Mac OS X.

Figure 1. iPhone New Project Template Dialog Box. The iPhone OS has a smaller set of templates compared to building applications for Mac OS X.

As you can see, there are two sets of templates in the New Project dialog box:

  • iPhone OS
  • Mac OS X

Xcode can be used to develop applications for both iPhone OS and Mac OS X. The number of new project templates available under Mac OS X far exceeds the templates available for iPhone OS.

In this Xcode (version 3.1.1), following templates are available are available for an iPhone application:

  • Navigation-Based Application
  • OpenGL ES Application
  • Tab Bar Application
  • Utility Application
  • View-Based Application
  • Window-Based Application

The iPhone applications are developed using Objective-C programming language. However, for Mac OS X applications, several other new project templates for different languages exist. For example, C++, Python, and Ruby can be used for developing Mac OS X applications, in addition to the usual Objective-C.

A Navigation-Based Application

For this example, the template “Navigation-Based Application” is selected. And it is saved as “FirstApp”.

Figure 2. First iPhone Application. By default this project and its content are saved into the Documents folder (which, of course, can be changed)

Figure 2. First iPhone Application. By default this project and its content are saved into the Documents folder (which, of course, can be changed)

The Project Window

Depending on the chosen template, a project with a set of source files will be created and opened in the project window. In the project window, you will see the header files (with .h extension), implementation files (with .m extension), user interface files (with .xib extension), property file (with .plist extension) and others.

Figure 3. The project window. It contains a navigation section of Groups and Files on the left, a detail window at the top and a code / editor window at the bottom.

Figure 3. The project window. It contains a navigation section of Groups and Files on the left, a detail window at the top and a code / editor window at the bottom.

By default, you can see the files in this FirstApp project separated into following groups:

  • Classes
  • Other Sources
  • Resources
  • Frameworks
  • Products

The header files (.h) and implementation files (.m) that declare and implement classes are shown under Classes group. The main() method and precompiled headers are shown under Other Sources. Resources are user interface files and other information files. Frameworks are the libraries that contain the Cocoa code. These files have .framework extension (CoreGraphics.framework, UIKit.framework, Foundation.framework, etc.).

This placing of source files into different groups (like Classes, Other Sources, etc.) can change from project to project (template to template). You can create your own groups as well, according to what makes sense for a particular project.

Compiling the iPhone Application

If you click on the Build and Go button, the project files will be compiled and the application will be opened in the iPhone simulator.

Figure 4. The compiled iPhone application in the simulator. This is a Navigation Based Application; hence it has a navigation bar at the top and a TableView. Since no data has been added, this view is empty.

Figure 4. The compiled iPhone application in the simulator. This is a Navigation Based Application; hence it has a navigation bar at the top and a TableView. Since no data has been added, this view is empty.

As you can see, this is an empty list application. The user interface for this list comes from the RootViewController.xib file. The class that supports the functionality is defined in the RootViewController.h header file. In this file, you can see the RootViewController class is derived from the UITableViewController and that class provides the basic list/table user interface you see in the above picture.

Figure 5. The default icon for iPhone First App is in the main screen of iPhone. Since no special icon is made for this application, an empty/default white icon is shown.

Figure 5. The default icon for iPhone First App is in the main screen of iPhone. Since no special icon is made for this application, an empty/default white icon is shown.

Clicking on the icon for the First App, that application will be started again. However, going to the home screen on iPhone (by clicking on the button at the bottom), the Xcode will close the debugging mode. If you start the application again from the iPhone Simulator, the application is not in the debugging mode automatically.

Take a Quick Quiz on this Article

1. Which language is used to develop applications for iPhone?



: C# is for Microsoft Windows environment
Question 1 of 5
Article Series
Previous Article:
Test Your Knowledge: Summary of various tools installed with iPhone SDK
This article is part of the Series:
Article Series: Getting started with iPhone development
Next Article:
Test Your Knowledge: Creation of First iPhone application explained
Bookmark and Share This

More Articles With Similar Tags
This is a test on the article that gives a quick overview of the development tools installed with iPhone SDK. These tools include Xcode, Interface Builder, Instruments, and iPhone Simulator. In the article, Dash Code, which is used to build web applications for iPhone is also introduced. GDB, the open source debugger, is discussed there as well.
icon-xcode-groups-files.jpg
This article discusses various parts of the Project window inside an Xcode project. It also gives a quick overview of the Groups and Files navigation window. The Run menu, the default toolbar, and the built-in source editor are also discussed.
This is a test on the article that discusses various parts of the Project window inside an Xcode project. It also gives a quick overview of the Groups and Files navigation window. The Run menu, the default toolbar, and the built-in source editor are also discussed.
icon-xcode-interface-builder-connection-panel.jpg
This article explains the user interface files of an iPhone application. Explains the contents of the .xib files, which store the user interface. Goes through the various windows (Document Window, User Interface Window, Inspector Window, Library Window, Connections Panel) of the Interface Builder. The example used is a simple navigation-based iPhone application.
This is a test on the article that explains the user interface files of an iPhone application. It explains the contents of the .xib files, which store the user interface. Goes through the various windows (Document Window, User Interface Window, Inspector Window, Library Window, Connections Panel) of the Interface Builder. The example used is a simple navigation-based iPhone application.
About  Contact  Privacy Policy  Site Map