Mobile Device Exploitation Cookbook
上QQ阅读APP看书,第一时间看更新

Setting up the iOS development environment - Xcode and iOS simulator

By now, you have got the hang of Android development. Now it's time to be introduced to the iOS development environment. Apple's iPhone and iPad run on the iOS operating system. Application development for iOS requires the Xcode IDE, which runs on Mac OS X. Xcode, together with iOS simulator, can be used to develop and test iOS applications.

Note

Note we say emulators when we talk about Android, and we say simulators when talk about iOS. These two are similar to each other, but with one major difference. An emulator can use some OS features to test specific applications.

For example, an Emulator can use a laptop's webcam to run an application that requires a camera, whereas such application testing will be limited in an iOS simulator. Emulators can also send an SMS to other emulators.

Some people say that emulators are smarter than simulators. However, generalizing that much may not be fair, as long as both serve the job they are designed for.

Getting ready

Xcode is the IDE for developing iOS applications. Xcode runs on Mac OS X, so a MacBook is required for iOS application development. So get a MacBook, install Xcode, install the iOS SDK, and start coding in iOS.

Note

Note that there are useful guidelines at https://developer.apple.com/programs/ios/gettingstarted/ to help you out with this.

How to do it...

Follow these steps for setting up Xcode and iOS simulator:

  1. Locate App Store on your MacBook. Now use App Store to download Xcode (this is just like any other App download on mobile phones). You will need an Apple ID to download from the App Store. Note that Xcode is free to download from Apple's App Store.
  2. Once Xcode is installed, you can explore the IDE. It can be used to develop Mac OS X applications. Xcode is a common IDE for both OS X applications and iOS application development. To be able to develop an iOS application, you also need to install the iOS SDK. The latest versions of Xcode include both OS X and the iOS SDK. Simulators and instruments are also part of Xcode now.
    • Thankfully this is not complicated and the installation of Xcode takes care of everything.
    • Once you have everything set up, create a new project. Note that if things are properly installed, you get the option to create an iOS and OS X application, as shown here:

How it works...

Let's make ourselves familiar with the Xcode IDE.

From the preceding screenshot, let's create a project. We will choose the Single View Application template for simplicity's sake. This action opens up the Choose options for your new project window. Provide a name for your project, which appends the organization identifier to create a bundle identifier.

Note we selected Swift, which is a new language introduced in iOS 8. There is another option, to choose traditional Objective-C.

Note

Swift is new programming language for iOS and OS X. It is interactive and is intended to make coding fun. Swift makes app development easier and can work alongside traditional Objective-C.

Some people say that emulators are smarter than simulators. However, generalizing that may not be fair, as long as both serve the job they are designed for.

Finally, it is also important that the appropriate device option is selected from iPhone, iPad, or Universal. We select iPhone, just for the sake of this demonstration.

Once you select Next and Create, we see our project window:

The left-hand pane is the project navigator. You can find all your project files in this area. The center part of the workspace is the editor area. Depending on the type of file, Xcode shows different interfaces in the editing area.

The right-hand pane is the utility area. This area displays the properties of files, and allows you to access Quick Help.

There's more...

Up to now we have written zero lines of code. Even so, we can run our app using the built-in simulator. In the toolbar, we can see the run button (top left, the one resembling the traditional play music icon):

When we hit the run button, Xcode automatically builds the app and runs it on the default iPhone 6 simulator. Of course, since we haven't programmed our app to do anything, it will just display a white screen with nothing inside:

The stop button next to the run button terminates the app.

See also

  • Setting up the iOS pentesting environment