The Application Bundle IPHONE APPS

When you build your iPhone application, Xcode packages it as a bundle. A bundle is a directory in the file system that groups related resources together in one place. An iPhone application bundle contains the application executable and any resources used by the application (for instance, the application icon, other images, and localized content). Table lists the contents of a typical iPhone application bundle, which for demonstration purposes here is called MyApp). This example is for illustrative purposes only. Some of the files listed in this table may not appear in your own application bundles.

A typical application bundle

A typical application bundle

An iPhone application should be internationalized and have a language.lproj folder for each language it supports. In addition to providing localized versions of your application’s custom resources, you can also localize your application icon (Icon.png), default image(Default.png), and Settings icon (Icon-Settings.png) by placing files with the same name in your language-specific project directories. Even if you provide localized versions, however, you should always include a default version of these files at the top-level of your application bundle. The default version is used in situations where a specific localization is not available.

You use the methods of the NSBundle class or the functions associated with the CFBundleRef opaque type to obtain paths to localized and nonlocalized image and sound resources stored in the application bundle. For example, to get a path to the image file sun.png (shown in “Responding to Interruptions”) and create an image file from it would require two lines of Objective-C code:

Calling the mainBundle class method returns an object representing the application bundle.

The Information Property List

The information property list is a file named Info.plist that is included with every iPhone application project created by Xcode. It is a property list whose key-value pairs specify essential runtime-configuration information for the application. The elements of the information property list are organized in a hierarchy in which each node is an entity such as an array, dictionary, string, or other scalar type.

In Xcode, you can access the information property list by choosing Edit Active Target TargetName from the Project menu. Then in the target’s Info window, click the Properties control. Xcode displays a pane of information similar to the example in Figure

The Properties pane of a target’s Info window

The Properties pane of a target’s Info window

The Properties pane shows you some, but not all, of the properties of the application bundle. When you click the “Open Info.plist as File” button, or when you select the Info.plist file in your Xcode project, Xcode displays a property list editor window similar to the one in Figure. You can use this window to edit the property values and add new key-value pairs. To see the actual key names added to the Info.plist file Control-click the Information Property List item in the editor and select Show Raw Keys/Values from the contextual menu that appears.

The information property list editor

The information property list editor

Xcode automatically sets the value of some of these properties, but others you need to set explicitly. Table lists some of the important keys that you might want to include in your application’s Info.plist file.

(Xcode obscures actual key names by default, so the string displayed by Xcode is also listed inparenthesis where one is used. You can see the real key names for all keys by Control-clicking the Information Property List key in the editor and choosing Show Raw Keys/Values from the contextual menu that appears.)

Important keys in the Info.plist file

string value in Info.plist should be a key to a localized string in the InfoPlist.strings file of a language-localized subdirectory.

Table lists the keys that you can include in the array or dictionary associated with the UI Required Device Capabilities key. You should include keys only for the features that your application absolutely requires. If your application can accommodate missing features by not executing the appropriate code paths, you do not need to include the corresponding key.

Dictionary keys for the UIRequiredDeviceCapabilities key

Dictionary keys for the UIRequiredDeviceCapabilities key

Application Icon and Launch Images

The file for the icon displayed in the user’s Home screen has the default name of Icon.png (although the CFBundleIconFile property in the Info.plist file lets you rename it). It should be a PNG image file located in the top level of the application bundle. The application icon should be a 57 x 57 pixel image without any shine or round beveling effects. Typically, the system applies these effects to the icon before displaying it. You can override that behavior, however, by including the UIPrerenderedIcon key in your application’s Info.plist file; for more information, see Table.

The file for the application’s launch image is named Default.png. This image should closely resemble the application’s initial user interface; the system displays the launch image before an application is ready t display its user interface, giving users the impression of a quick launch. The launch image should also be a PNG image file, located in the top level of the application bundle. If the application is launched through a URL, the system looks for a launch image named Default scheme.png, where scheme is the scheme of the URL. If that file is not present, it chooses Default.png instead.

To add an image file to a project in Xcode, choose Add to Project from the Project menu, locate the file in the browser, and click Add.

Nib Files

A nib file is a data file that stores a set of “freeze-dried” objects that the application plans to use later. Applications use nib files most often to store the windows and views that make up their user interface. When you load a nib file into your application, the nib-loading code turns the contents into real objects that your application can manipulate. In this way, nib files eliminate the need to create these same objects programmatically from your code.

Interface Builder is the visual design environment that you use to create nib files. You assemble nib files using a combination of standard objects (such as the windows and views provided by the UIKit framework) and custom objects from your Xcode projects. Creating view hierarchies within Interface Builder is a simple matter of dragging and dropping views in place. You can also configure the attributes of each object using the inspector window and create connections between objects to define their runtime relationships. All of the changes you make are subsequently saved to disk as part of your nib file.

At runtime, you load nib files into your application when you need the objects they contain. Typically, you load a nib file when your user interface changes and you need to display some new views on the screen. If your application uses view controllers, the view controller handles the nib loading process for you automatically but you can also load nib files yourself using the methods of the NSBundle class.

Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status