Create a new iOS Project in Xcode and then run it in the iOS Simulator using Command+Shift+R.
I’ll assume you have a Mac and you have already installed the Xcode set of tools. Now you want to create an iOS Project and run that app on the iOS Simulator. This process is really straightforward:
Open Xcode if you don’t have it open yet.
Select File on the menu bar, select New, and then select New Project. You will be greeted with a screen similar to that shown in Figure 1-1.
In the New Project dialog (Figure 1-1), on the left, make sure the Application category is selected under the iOS main category. Then select Page-Based Application on the right-hand side and press the Next button.
You will now need to enter your product name (App Name) and your company identifier. This uniquely identifies your product for your own company. Set your product name to Creating a Simple iOS App in Xcode. The company identifier is normally a domain name with the components reversed. My company name is Pixolity, and therefore I will set the Company Name to
com.pixolityas shown in Figure 1-2. Leave the rest of the values in this screen just the way I’ve left them in Figure 1-2 and press the Next button.
You will now be asked to save your project on a disk. Select your desired location and press the Create button, as shown in Figure 1-3. Xcode will now create your project files and the structure of your project.
Now, before running your app, make sure you have unplugged any iPhones or iPads/iPods that you have connected to your computer. The reason behind this is that if a device is connected to your Mac, Xcode will try to run your apps on the device instead of the simulator, and if you haven’t configured your device for development, you might get blocked and not be able to run your apps.
From the drop-down on the top-left corner of Xcode, make sure iPhone Simulator or iPad Simulator is selected. In this example, I will make sure iPad Simulator is selected, as shown in Figure 1-4.
Now that everything is ready, press the Command+Shift+R keys on your keyboard or simply go to the Product menu and then press the Run button as shown in Figure 1-5.
Congratulations. Now you have a simple app running in iOS Simulator. As you saw, there are various different iOS project templates that you can choose from (Figure 1-1). Here is a list of some of the handy project templates that you can use:
- Master-Detail Application
This project template will set up a split view controller for your us. Split view controllers are explained in Chapter 2, Implementing Controllers and Views.
- Page-Based Application
This template will allow your app to have an iBooks user interface, where the user will be able to flip through the pages that are drawn by the app. You’ll learn more about this in Chapter 2.
- Empty Application
An empty application is simply made out of the most basic components that any iOS app has. I use this template a lot to set up my iOS apps the way I like them to be set up, without any preconfiguration by Xcode.