Updated for Xcode 9.
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:
Down the right side you will have a list of projects that you have recently opened. To set up a new project, click on “Create a New Xcode Project”.
Ensure that iOS is selected in the top menu. You can then select Single View App, and then click Next. Please note that these are just templates. If you wanted to create an Augmented Reality App you could start with a single view app and then add in the necessary framework and code to still create an Augmented Reality App. The templates just act as convenient starter projects to get you going. For many of the tutorials on DevFright we will start from the Single View App.
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. You can change the product name at any point, but the folder name where the project is stored on your Mac will retain this name.
Team is populated by the name on your developer account. Depending on what type of developer account you have will depend on what is available here. None is OK if you are just testing, but you might select your business name or personal name from this dropdown.
The Organization Name is your business name. I just put DevFright here, or for projects for clients I put TechAsis Limited which is my company name.
Organization Identifier is often recommended to be written in reverse notation. So in this case com.devfright was used because this website is devfright.com. There is no real link between organization identifier and your actual domain name though. I just recommend using your domain name as it’s unique to you. The key here is that if you upload an app to be included in the app store, the bundle identifier needs to be unique. Note that in the next line it says Bundle Identifier which is pre-populated with your organization identifier and product name.
Language is used to select between Swift or Objective-C. For all current tutorials we are focusing on Swift with it being a newer language.
The last 3 options will typically be switched off for our tutorials, unless the tutorial is about Core Data or unit or ui tests. If you switch them on, it isn’t a problem though.
Click Next and you will be presented with the finder where you can choose where you want to save the project. You will also have a check box which enables or disables Git repositories. Feel free to leave this enabled or disabled. I would recommend you enable it on real projects though.
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 as well as the version number of the app and the “development target” which means what iOS will the app be combatible with.
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.