requirements for iOS development How to obtain the iPhone SDK Components included in the iPhone SDK Features of the development tools — Xcode, Interface Builder, iPhone Simulator Capabilities of the iPhone Simulator Architecture of the iPhone OS Characteristics of the iPhone OBTAIN THE IPHONE SDKS To develop for the iPhone, you first need to sign up as a registered iPhone developer at http://developer .apple.com/iPhone/program/start/register/. Registration is free and provides you with access to the iPhone SDK (software development kit) and other resources that are useful for getting started. NOTE At the time of writing, iOS (the iPhone OS) 4 is supported only on the iPhone and the iPod touch. The iPad still runs on the older iPhone OS 3.2 version. However, the iPhone SDK 4.0 supports both iPhone and iPad development. Because the iPad also uses the iPhone OS, throughout this book you will often see the term “iPhone” used. After signing up, you can download the iPhone SDK (version 4; see Figure ). 1 requirements for iOS development SYSTEM REQUIREMENTS ✴.Only Intel Macs are supported, so if you have another processor type (such as the older G4 or G5 Macs), you’re out of luck. ✴Your system is updated with the latest Mac OS X release. ✴An actual iPhone/iPad is highly recommended, although not strictly necessary. To test your appli- cation, you can use the included iPhone Simulator (which enables you to simulate an iPhone or an iPad). However, to test certain hardware features like GPS, the accelerometer, and such, you need to use a real device. When the SDK is downloaded, proceed with installing it (see Figure 1-2). Accept a few licensing agreements and then select the destination folder in which to install the SDK. jhjhjhj If you select the default settings during the installation phase, the various tools will be installed in the /Developer/Applications folder 2 requirements for iOS development COMPONENTS INCLUDED IN THE IPHONE SDK The iPhone SDK includes a suite of development tools to help you create applications for your iPhone, iPod touch, and iPad. It includes the following: ✴Xcode — Integrated development environment (IDE) that enables you to manage, edit, and debug your projects ✴Dashcode — Integrated development environment (IDE) that enables you to develop web- based iPhone and iPad applications and Dashboard Widgets. Dashcode is beyond the scope of this book. ✴iPhone Simulator — Provides a software simulator to simulate an iPhone or an iPad on your Mac. ✴Interface Builder — Visual editor for designing user interfaces for your iPhone and iPad applications ✴Instruments — Analysis tool to help you both optimize your application and monitor for memory leaks in real time Xcode To launch Xcode, double-click the Xcode icon located in the /Developer/Applications folder (refer to Figure 1-3). Alternatively, go the quicker route and use Spotlight: Simply type Xcode into the spotlight and Xcode should be in the Top Hit position. 3 requirements for iOS development XCODE WELCOME SCREEN Using Xcode, you can develop different types of iPhone, iPad, and Mac OS X applications using the various project templates shown in Figure 1-5. Each template gives you the option to select the platform you are targeting — iPhone or iPad. 4 requirements for iOS development Note that not every application template is available for iPhone and iPad. For example, Navigation-based application templates do not support the iPad, and Split-View application templates do not support the iPhone. The IDE in Xcode provides many tools and features that make your development life much easier. One such feature is Code Sense (see Figure 1-6), which displays a popup list showing the available classes and members, such as methods, properties, and so on. IPHONE SIMULATOR IS NOT AN EMULATOR To understand the difference between a simulator and an emulator, keep in mind that a simulator tries to mimic the behavior of a real device. In the case of the iPhone Simulator, it simulates the real behavior of an actual iPhone/iPad device. However, the Simulator itself uses the various libraries 5 installed on the Mac (such as QuickTime) to perform its rendering so that the effect looks the same as an actual iPhone. In addition, applications tested on the Simulator are compiled into x86 code, which is the byte-code understood by the Simulator. A real iPhone device, on the other hand, uses ARM-based code. In contrast, an emulator emulates the working of a real device. Applications tested on an emulator are compiled into the actual byte-code used by the real device. The emulator executes the application by translating the byte-code into a form that can be executed by the host computer running the emulator. A good way to understand the subtle difference between simulation and emulation is this: Imagine you are trying to convince a child that playing with knives is dangerous. To simulate this, you pretend to cut yourself with a knife and groan in pain. To emulate this, you actually cut yourself. requirements for iOS development iPhone Simulator The iPhone Simulator, shown in Figure 1-7, is a very useful tool that you can use to test your application without using your actual iPhone/iPod touch/iPad. The iPhone Simulator is located in the /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications folder. Most of the time, you don’t need to launch the iPhone Simulator directly — running (or debugging) your application in Xcode automatically brings up the iPhone Simulator. Xcode installs the application on the iPhone Simulator automatically. 6 requirements for iOS development Features of the iPhone Simulator The iPhone Simulator simulates various features of a real iPhone, iPod touch, or iPad device. Features you can test on the iPhone Simulator include the following: • Screen rotation — left, top, and right. • Support for gestures: Tap • Touch and Hold Double-tap Swipe Flick • Drag • Pinch • Low-memory warning simulations However, the iPhone Simulator, being a software simulator for the real device, does have its limitations. The following features are not available on the iPhone Simulator: ✓ Making phone calls ✓ Accessing the accelerometer ✓ Sending and receiving SMS messages Installing applications from the App Store ✓ Camera ✓ Microphone ✓ Several features of OpenGL ES NOTE: In the previous version of the SDK (3.1.3), the iPhone Simulator supports location data by always returning a ﬁxed coordinate, such as Latitude 37.3317 North and Longitude 122.0307 West. In the newer release of the SDK (3.2 and later), the iPhone Simulator uses the location data of the Mac it is currently running on to return the current location. 7 Note also that the speed of the iPhone Simulator is more tightly coupled to the performance of your Mac than the actual device. Therefore, it is important that you test your application on a real device, rather than rely exclusively on the iPhone Simulator for testing. Despite the iPhone Simulator’s limitations, it is deﬁnitely a useful tool for testing your applications. That said, testing your application on a real device is imperative before you deploy it on the App Store. requirements for iOS development Uninstalling Applications from the iPhone Simulator The user domain of the iPhone OS file system for the iPhone Simulator is stored in the ~/Library/ Application Support/iPhone Simulator/ folder. NOTE The ~/Library/Application Support/iPhone Simulator/ folder is also known as the <iPhoneUserDomain>. All third-party applications are stored in the <iPhoneUserDomain>/<version_no>/Applications/ folder. When an application is deployed onto the iPhone Simulator, an icon is created on the Home screen (shown on the left in Figure 1-9) and a ﬁle and a folder are created within the Applications folder (shown on the Figure ). To uninstall (delete) an application, execute the following steps: 8 1. Click and hold the icon of the application on the Home screen until all the icons start wriggling. Observe that all the icons now have an X button dis- played on their top-left corner. 2. Click the X button (see Figure ) next to the icon of the application you want to uninstall. 3. An alert window appears asking if you are sure you want to delete the icon. Click Delete to conﬁrm the deletion. When an application is uninstalled, the corresponding ﬁle and folder in the Applications folder are deleted automatically. requirements for iOS development The easiest way to reset the iPhone Simulator to its original state is to select iPhone Simulator ➪ Reset Content and Settings. 9 requirements for iOS development INTERFACE BUILDER Interface Builder is a visual tool that enables you to design the user interfaces for your iPhone/iPad applications. Using Interface Builder, you drag and drop views onto windows and then connect the various views with outlets and actions so that they can programmatically interact with your code. instruments The Instruments application (see Figure) enables you to dynamically trace and proﬁle the performance of your Mac OS X, iPhone, and iPad applications. 10 requirements for iOS development Using Instruments, you can do all of the following: • Stress test your applications • Monitor your applications for memory leaks • Gain a deep understanding of the executing behavior of your applications • Track difficult-to-reproduce problems in your applications Architecture Of the iPhone OS Although this book doesn’t explore the innards of the iPhone OS, understanding some of its important characteristics is useful. Figure 1-16 shows the different abstraction layers that make up the Mac OS X and the iPhone OS (which is used by the iPhone, iPod touch, and iPad). NOTE : The iPhone OS is architecturally very similar to the Mac OS X except that the topmost layer is Cocoa Touch for iPhone instead of the Cocoa Framework. CORE OS LAYER The bottom layer is the Core OS, which is the foundation of the operating system. It is in charge of memory management, the ﬁle system, network- ing, and other OS tasks, and it interacts directly with the hardware. The Core OS layer consists of components such as the following: • OS X Kernel • Mach 3.0 11 • BSD • Sockets • Security • Power Management Keychain Certiﬁcates • File System Bonjour requirements for iOS development CORE SERVICES LAYER FOR IPHONE The Core Services layer provides an abstraction over the services provided in the Core OS layer. It provides fundamental access to iPhone OS services and consists of the following components: •Collections •Address Book •Networking •File Access •SQLite •Core Location •Net Services •Threading •Preferences •URL Utilities Media layer The Media layer provides multimedia services that you can use in your iPhone and iPad applications. It 12 consists of the following components • Core Audio • OpenGL • Audio Mixing • Audio Recording • Video Playback • JPG, PNG, TIFF PDF • Quartz • Core Animation OpenGL ES requirements for iOS development COCOA TOUCH LAYER The Cocoa Touch layer provides an abstraction layer to expose the various libraries for programming the iPhone and iPad, such as the following: • Multi-Touch events • Multi-Touch controls • Accelerometer • View Hierarchy Localization • Alerts • Web Views • People Picker • Image Picker • Controllers 13 this is intentionally left blank write the first hello world application what you will learn in this chapter • How to create a new iPhone project • Building your first iPhone application using Xcode • Designing the user interface (UI) of your iPhone application with Interface Builder • How to add an icon to your iPhone application • HOW TO CREATE A NEW IPHONE PROJECT 15 To create a new iPhone project, choose File ➪ New Project. Figure shows the different types of projects you can create using Xcode. The left panel shows the two primary categories — iPhone OS and Mac OS X. The iPhone uses the iPhone OS (which has since been renamed as iOS), so click the Application item listed under iPhone OS to view the different templates available for developing your iPhone application. write the first hello world application IOS BASIC TEMPLATE IS VIEW BASED TEMPLATE Although there are quite a few types of iPhone applications you can create, select the window-based Application template.Actually window based template is basic template for objective c concepts and for the product, select iPhone (to target the iPad, select the iPad as the product). Click the Choose... button. for the view based template. WINDOW BASED TEMPLATE 16 Name the project Hello and click Save. Xcode proceeds to create the project for the template you have selected. Figure 2-3 shows the various ﬁles and folders automatically created for your project. side ﬁgure shows saving of window based template. write the first hello world application PANEL OF XCODE FOR WINDOW BASED TEMPLATES The left panel of Xcode shows the groups in the project. You can expand each group or folder to reveal the files contained in it. The right panel of Xcode shows the files contained within the group or folder you have selected from the left panel. To edit a particular file, select it from the list, and the editor at the bottom of the right panel opens the file for editing. If you want a separate window for editing, simply double-click the file to edit it in a new window. 17 write the first hello world application VIEW BASED TEMPLATES Create a new view based template from below screen. go to File --> New project You get a pop up window below fig.Now choose view based template. VIEW BASED TEMPLATES NAMED FILE NAME “HELLOVIEW” 18 write the first hello world application HELLOVIEW PROJECT FILES PANEL OF XCODE FOR VIEW BASED TEMPLATES The left panel of Xcode shows the groups in the project. You can expand each group or folder to reveal the files contained in it. The right panel of Xcode shows the files contained within the group or folder you have selected from the left panel. To edit a particular file, select it from the list, and the editor at the bottom of the right panel opens the file for editing. If you want a separate window for editing, simply double-click the file to edit it in a new window. 19 interface builder write the first hello world application HELLOVIEW PROJECT FILES PANEL OF XCODE FOR VIEW BASED TEMPLATES The left panel of Xcode shows the groups in the project. You can expand each group or folder to reveal the files contained in it. The right panel of Xcode shows the files contained within the group or folder you have selected from the left panel. To edit a particular file, select it from the list, and the editor at the bottom of the right panel opens the file for editing. If you want a separate window for editing, simply double-click the file to edit it in a new window. 20 interface builder requirements for iOS development XCODE 4 WITH MAC OS X AND IOS SDKS(AVAILABLE ON APPSTORE) click on this icon from Launchpad . If you have apple id and password you can get this from Appstore. Appstore id and password is required to download. App store can create apple id by taking your personal information with mail account as id . ex:firstname.lastname@example.org To buy an App you also need credit card for your details. For downloading Xcode 4 you just need your personal data like your address,your name, etc. 21 requirements for iOS development xcode 4.2.1 Available in App store for free. welcome screen for Xcode 4.2.1 22
"iphone introduction xcode"