ERNI Technology Post No. 32 - iPhone Development

iPhone  applications  (“apps”)  are  a  hot  topic  nowadays  and  the  community  of  app  users  is  growing  daily. Moreover, the number of people thinking of developing their own iPhone apps – whether for business or personal use – is also increasing. Finally, the community of people who have experience with the iPhone platform’s development process is growing significantly, too. This Technology Letter is targeted at the latter two groups: The first part contains basic information to simplify the entry into the world of app development. This includes a simple “Hello World” application as an example. The second part is focussed on testing as well as the process of submitting an app for inclusion in the App Store. For example, if encryption is used, there are some time-consuming additional steps that are involved in the process.

Part 1 - Introduction and sample app

Getting started fast with iPhone development The prerequisite for development of iPhone apps is an up-to-date Apple computer along with registration in Apple’s iPhone Developer Program [1]. A free license is adequate to get started. However, the standard developer program (price USD 99) is required in order to distribute apps to phones and publish them in the App Store. Once the registration process is complete, the necessary programs such as the SDK and XCode development environment with simulator, Interface Builder and debugger can be downloaded. There are many publications that exist to help learning to develop apps. Highly recommended are, e.g. [2] and [3]. Some useful development manuals are also available online, e.g. [4] and [5].

"Hello World" on the iPhone

In the following sections, we will discuss the most important building blocks and basic principles involved in iPhone development. Cocoa is a collection of object-oriented frameworks developed by Apple that serves as the basis for app development. Cocoa has a runtime environment for applications that run on Mac OS X and the iPhone OS and uses the Objective-C language, which is an object-oriented extension of C with late binding that is based syntactically on Smalltalk.

Messaging in Ojective-C

Fig. 1: Messaging in Objective-C

Newcomers will be unfamiliar with the concept of messaging in Objective-C. A message expression consists of a receiver (object) and a message (method name with arguments) enclosed in square brackets (Fig. 1). In case of multiple arguments, the method name is divided up to allow better correlation of the arguments. The call to set a rectangle with, say, a given height and width using the method setWidth:andHeight is as follows: [rectangle setWidth:width and Height:height]; Delegation is an important pattern in Cocoa. Tasks are delegated to provided API classes. One of its benefits compared to inheritance is that a delegate can be called by many different host classes without requiring – in contrast to subclassing – an inheritance. MVC (Model, View, Controller) is another important concept. Views and the related program code in the controllers and models are easy to connect in the Interface Builder by clicking and dragging connecting lines.

MVC concept with example

Fig. 2: MVC concept with example

 

These concepts can be readily illustrated using a familiar “Hello World” coding example. The steps to create this sample app are as follows:

Files in the "Hello World" app

Fig. 3: All files in the "Hello World" app

1.   Create a new “Window-based Application” project in XCode and call it “Hello_World”. This will automatically generate all of the required controllers and delegates (Fig. 3). 2.   Double-click the file “Hello_WorldViewController.xib” and drag a RoundRectButton and a label to the view in the Interface Builder. Delete the label text and label the button with “Say hello”. 3.   Now we must declare the label as an outlet in the header file of the Hello_WorldViewController and also declare a method that responds to a sender’s view actions: the “Say hello” button.

Hello world view controller 

4.   The next step involves the connection in the Interface Builder from the controller with the label as the receiver and the button as the sender. A Ctrl-Drag from the “File’s Owner”, the representation of the ViewController, to the label opens a popup window for selection of the declared outlet, the writeHelloLabel. A Ctrl-Drag from the button to the “File’s Owner” opens a popup window for selection of the declared events, the buttonPressed method. 5.   As the final step, the actual code in the buttonPressed method must now be inserted directly at the start of the implementation of the Hello_WorldViewController.

Hello worldview controller 

The @synthesize line generates automatic setter and getter methods for the label (setText and Text) without having to write this code. The string *newText is assigned the title of the button with the addition of “World!”. The entire string “Say hello World!” is now assigned to the label, and the temporary variable is then released. 6.   Now we can compile and run the Hello_World app (Build > Build and Run menu). The iPhone simulator opens by default and the results will appear as shown in Fig. 4 before and after clicking the button.

 Completed "Hello World" sample app

Fig. 4: Completed "Hello World" sample app

The complete source code for the Hello_World example is available online here [6]. It was created under XCode 3.2.3 with Base SDK iOS 4.0.

Part 2 - Testing and activation

Testing for iPhone apps Any new application must be tested on all of the current iPhone models and if relevant, also on the iPad. It is important to also test with the last two to three versions of the operating system on the phones. This means that several phones must be available for testing purposes. The duration and complexity of this test process should not be underestimated. Any version that is uploaded to the App Store must first undergo internal testing. Even small changes can generate errors on certain phone models or with certain iOS versions. We will discuss the three typical test phases now.

(1) Testing with the simulator

The developer can begin testing the app during the actual development process. However, the iPhone simulator does not replicate all of the phone’s functionality, i.e. all of the hardware-specific functions such as creation of a photo directly from an app, GPS positioning and user interactions that involve tilting the phone or finger gestures are not available. This limitation became apparent, for example, during the introduction of iPhone 4 accompanied by the simultaneous switch to iOS 4. Since there were not any test phones available at the time of the market launch, many developers were limited during an initial phase to testing their apps on the iPhone simulator – with no support for hardware-specific functions.

(2) Ad-hoc tests

In order to allow “ad hoc” testing of apps on the hardware, Apple has created the “iPhone Provisioning Portal” [7]. Apps can be tested on a maximum of 100 registered phones in this manner. A new application profile must first be created in the portal in order to have access to “ad hoc” testing. The test phones are saved in this profile along with their device identification. Based on this information, Apple generates what is known as a “provisioning file”. This file is linked with the application during creation of the binaries in XCode. This ensures that the application can run only in conjunction with the proper provisioning file and phone ID. Next, the test version of the app and the provisioning profile can be distributed, e.g. via e-mail and then installed via iTunes. Any existing older versions of the app should be deleted from the phone and in iTunes prior to testing a new version. Next, it is necessary to synchronize and verify that the app is no longer installed at both locations. Now, the app and the provisioning file can be accessed using a drag & drop procedure in iTunes. Following another synchronisation procedure, the app is available on the phone.

(3) Apple review process

Apple tests any app that is to be published as part of its own review process. The focus here is on compliance with usability guidelines, adherence to naming conventions and exclusion of banned content and functions – in addition to a general test of the functionality.

From completed app to AppStore

Once the application development process has been completed including internal testing, the app can be submitted to Apple for inclusion in the App Store (Fig. 5).

"iTunes Connect"

Apple provides the “iTunes Connect” web tool for this process [8]. The Apple ID for the developer program can also be used to access iTunes Connect. This allows usage of the following functions:

  • App management including sales prices, user reviews, information for the Apple review team and crash logs for common errors

  • Activation of free downloads of apps for selected persons

  • Statistics and reports (sales, App Store, iAd program)

  • Status of agreement with Apple (app sales, iAd program, banking information, tax-related information)

  • Management of additional Apple IDs for access to iTunes Connect

In order to submit a new app, the name, description and classification in terms of the App Store categories are needed, along with support information and the company’s homepage. Logos and screenshots are very important since this is how potential users will gain a first impression of the app. Here, Apple has specific mandatory guidelines for the size and formats. The information is saved in English, but other languages such as German can also be included additionally with separate screenshots. In its Developer Guide, Apple provides some tips for optimising marketing through iTunes. If encryption is used, e.g. for data transmission between the app and server or for secure data storage within the app itself, a special approval is required from the American government (CCATS, see [9]). This is necessary because Apple is responsible for distribution of the app and American companies are subject to NSA restrictions on the export of encryption technology. This approval can take from four to eight weeks. Until the approval is received, the app cannot be submitted for testing to Apple in iTunes Connect. Useful instructions are found under [10]. The application to be tested is uploaded using Apple’s “Application Loader” program which is found in the iPhone SDK. Apple then performs initial testing of the app's binary. Each further release of the app is also subject to the Apple review process. Depending on what is involved, e.g. new iOS releases, new hardware, etc., it takes about 3 to 15 days until a new version is approved. Once the app is released, it is available in the App Store and users can purchase it. Distribution statistics can be found in iTunes Connect.

Summary

iPhone apps are a truly fascinating world, and their popularity remains extremely high. This Technology Letter has described how it is possible to get started with the development of apps relatively quickly thanks to the large volume of information and manuals available to assist developers. Of course, Apple provides good support in the form of the relevant tools and modules.

References

[1] iPhone Developer Program: http://developer.apple.com/iphone/

[2] Dave Mark & Jeff LaMarche: Beginning iPhone Development - Exploring the iPhone SDK. ISBN: 978-1-4302-1626-1

[3] Aaron Hillegass: Cocoa Programming for Mac OS X. ISBN: 978-0321503619

[4] Fast start for iPhone developers: http://developer.apple.com/iphone/library/navigation/index.html

[5] Big Nerd Ranch: http://www.bignerdranch.com/

[6] Source Code for the Hello_World example: http://www.erni.ch/dateien/dokumente/Hello_World.zip

[7] iPhone Provisioning Portal: https://developer.apple.com/iphone/my/overview/index.action

[8] iTunes Connect: https://itunesconnect.apple.com

[9] Information about exporting encryption technology from the USA: http://www.bis.doc.gov/licensing/cclrequestguidance.html

[10] Guidelines for iPhone applications with encryption: http://www.zetetic.net/blog/2009/08/03/mass-market-encryption-commodity-classification-for-iphone-applications-in-8-easy-steps/

Memcache statistics

Operation Bin Key Hit
get cache_bootstrap erniconsultants_-cache_bootstrap-variables 1
get cache_bootstrap erniconsultants_-cache_bootstrap-bootstrap_modules 1
get cache_bootstrap erniconsultants_-cache_bootstrap-lookup_cache 1
get cache_bootstrap erniconsultants_-cache_bootstrap-variable%3Alanguage%3Aen 1
get cache_bootstrap erniconsultants_-cache_bootstrap-system_list 1
get cache_bootstrap erniconsultants_-cache_bootstrap-module_implements 1
get cache erniconsultants_-cache-omega%3Aerni%3Aextensions 1
get cache_path erniconsultants_-cache_path-ckeditor%2Fxss  
get cache_libraries erniconsultants_-cache_libraries-colorbox 1
get cache erniconsultants_-cache-context 1
getMulti cache erniconsultants_-cache-.wildcard-context 1
get cache erniconsultants_-cache-ctools_plugin_type_info 1
get cache erniconsultants_-cache-plugins%3Acontext%3Aplugins 1
getMulti cache erniconsultants_-cache-.wildcard-plugins%3Acontext 1
get cache erniconsultants_-cache-schema%3Aruntime%3A 1
getMulti cache erniconsultants_-cache-.wildcard-schema%3A 0
get cache erniconsultants_-cache-context 1
set cache erniconsultants_-cache-context  
get cache erniconsultants_-cache-context 1
set cache erniconsultants_-cache-context  
get cache erniconsultants_-cache-theme_registry%3Aerni 1
getMulti cache erniconsultants_-cache-.wildcard-theme_registry 1
get cache erniconsultants_-cache-filter_formats%3Aen 1
get cache erniconsultants_-cache-filter_list_format 1
posted on 17.07.2012
Categories: 
by: Tobias Kluge