In this tutorial I will walk you through setting up your first Xcode project so that you can begin working on your first app. If you haven’t installed Xcode yet you can either grab it from the Mac App Store, or if you have an Apple iOS developers account you can download the latest beta version from within there.
Now that you have Xcode installed, it’s time to load it up. Upon loading Xcode you get the following screen:
If you do not see the above screen load up when you start Xcode, click File > New Project and this is what you will be presented with. The left hand column shows what you are developing for, in this case you will see Application is highlighted within the iOS category as I am going to be showing you how to create your first iOS project within Xcode.
The right hand pane shows 7 different types of projects you can create (depending on what version of Xcode you have you might see some slight variation to the available options here). It is worth pointing out that if you choose one particular project template then you are not necessarily stuck with that type of app as it is simply a template or a starting point. I typically just go for the Single View Application option as I can add in page based, tabbed based and any other options I need as I begin creating the application.
After clicking next, you are presented with more options:
Starting from the top we have:
Product Name which is what your app will be called. Choose something relatively short here as iTunes restricts the length of the name that is visible in the app store… so if you can fit it in to fewer characters (perhaps 10 or 11) then they will all be visible in the App Store on the main screen.
Organization Name is what your company name is or your own name if publishing apps as an individual.
The company Identifier should take the format of com.appname.yourcompany, so for the above it should read com.mycoolapp.mycompanylimited.
Class Prefix is the prefix used before class names (not too surprising there). This means that when you load up your project you will see myCoolAppAppDelegate.m/h as file names as well as a myCoolAppViewController.m/h.
Depending on what device(s) you want to create your app for, you can select either Universal which means both iPad and iPhone or either iPad or iPhone. If you select just iPhone, you can always modify your app at a later date to include the iPad with just a few changes.
My preference is to use Storyboards as well as Automatic Reference Counting. If you are new to iOS developing then you will probably be best using these options. Switching them off in some cases also makes sense, but for beginners it is worth leaving them active.
The next option after clicking Next is to specify a folder location for your app. My preference is under my username on my Mac and then in a folder called Developer. The folder name is created automatically and is based on the Product Name that you entered above.
Before clicking Create, the final option you have on the screen is to select Source Control being on or off with a local git repository. I tend to select this option by default as it allows you to easily create snapshots while you work through developing your app and effectively re-wind if you need to step back a little to an earlier version.
Now that you have saved your new app, you are now ready to begin working on it. I’ve gone a bit more in to detail in the post, How to Learn Xcode but just a brief run down here, the left column are all your files that you work with. This includes your code, the app delegate, frame works and any other supporting files. These files can easily be moved around and grouped as needed to help keep things a little more organised. The right hand column shows the object library and quick help although the top side also changes in to an inspector when needed. The side columns can be slid out of the view with the View buttons at the top right of the screen.
The middle section is typically where your code will appear… ie, where you will write your programs, statements etc… but in the screenshot what you see is the main config of the app. In this section you can make a few settings changes such as what device orientations your app is compatible with along with the icons for the app as well as the version number of the app and the “development target” which means what iOS will the app be combatible with.
Scrolling further down you have the options to add frameworks to your apps. Frameworks are either created by Apple or manually attached from 3rd party downloads. I’ll go over frameworks in a later post, but one example of a framework is the MapKit which essentially allows you to add maps to your app. This framework tends to be coupled with the Core Location framework which adds location functions to your app which you can call on when needed.
Although I showed you the very basics today of setting up a project for your iOS app, Xcode goes a lot more in to detail. There are a huge amount of options and checkboxes that you can select which at the moment are a bit in-depth to go in to. What you’ll find is that you will find out new options as and when you need them rather than all at once in a quick study session. Just be aware that there are various options which can change the way your app functions.
Now that you have your project set up, it’s now time to start developing your app by clicking on one of the files in the sidebar. I might suggest here that the storyboard is often a good place to get going as it allows you to quickly put together what the app looks like at which point you can then start to attach it to the code through outlets and actions and then begin implementing those features.
Any questions, drop a comment below.