Tuesday, August 16, 2011

[iOS Development] How to Create Hello World Application for iOS using Xcode





I’ve recently taken it upon myself to get into iOS development. I use iOS on a daily basis on my iPhone and got an interest to start developing for the devices as well.

Starting Point
  • Basic knowledge of  C and hopefully some Object Oriented programming, iOS SDK uses Objective-C, which is a superset of the C language.
  • iOS development is done using 2 main programs, Xcode and the Interface Builder (there is also the iOS simulator, which is used to test your apps at first).
  • All development toolkit which run solely on Intel based Macs. So unfortunately if you’re a PC and not a Mac you’re a bit stuck.
Development Environment
Firstly let’s have a look at those programs you’ll be using to develop for iOS, starting with Xcode.Open  the xcode application (easiest way to do so is to use spotlight and type xcode and run the application from there, or you can find xcode in /Developer/Applications/).

Step -1 :
Opening splash screen for Xcode which gives you the option to start a new project or open an existing project.Select “Create a new Xcode project”, click that and you’re brought to below figure.

Step -2 :
 Next you can able to see different projects you can create. For this "Hello World" example select the “View based application” and save it in a directory you’re happy with (I’ve set up a developer directory for all of my projects to go into).
Step - 3 :
Once you’ve chosen a name for your project the next screen you’re brought to workspace of Xcode.
iRamTestAppViewController.xib” is the Interface Builder file that Xcode created for you when you selected a ‘View-based application’; the XIB file contains your view, and ‘iRamTestAppViewController.m’ is your view controller, but that’s not important for now.Double clicking “iRamTestAppViewController.xib” will open your xib file in Interface Builder.


Step - 4 :
Drag a label from the library to your view.By default Interface Builder will add a View to your XIB which will display when your XIB file is opened. 
To the left of your view in Interface Builder, there is a window called “Library”, the library contains objects for controls and views you can use in your interface. For this tutorial we just need a label, so find the ‘Label’ object in the library, then click and drag it onto your view.

Step - 5 :
To Customize the labelChange the text on the label to “Hello World’ by double clicking the label and typing “Hello World” and hitting return. While the label object is still selected, use the Attributes Inspector (to the right) to change some of the appearance attributes of the label, in this  example I changed the font size to 58, and added a shadow with a 1 pixel horizontal and vertical offset. 

Step - 6 :
Now you set to go .In Xcode click the ‘Build & Run’ button at the top of the Project Window, this will build your app bundle and run the app in the iPhone simulator.


From this Tutorial, you can able to create simple application for iOS using XCode. Coming week will walkthrough about Objective -c, Cocaco Touch Frameworks and UI designs.


















No comments:

Post a Comment