Let's begin!

Create a repository and initialize a project in Xcode.

This project will be a base for all other projects, we will use it to initialize new projects, rather than creating a new project in Xcode each time.

Repository

Let’s start with a repository. Whether you work alone or with a team it’s a good practice to use a repository to handle all of the code. I use git and strongly suggest you to use it too. You can create a free account on GitHub or Bitbucket or even keep it as local repository.

After you have created a new repository, and before we generate a new project in Xcode, it’s a good idea to ignore some files using .gitignore. Just in case you don’t know what it is, you can read more about it here.

We need to ignore a couple of unnecessary files from:

  • OSX
  • Xcode
  • AppCode
  • CocoaPods

The whole .gitignore file that I use is available here. On this website you can easily generate your own gitignore file. Just choose the language or IDE you use.

Create a new project with Xcode

Now it’s time to start our journey with Xcode. I will be using the latest version of Xcode that is available at this moment, which is Version 8.2.1 (8C1002).

Open Xcode and create New Project (⇧ ⌘ N):

Create new project

Type the project name, choose Swift and check Include Unit Tests:

Choose options

Right now we have a plain simple iOS app. Let’s tweak it a little bit.

First of all, let’s rename tests target. To do this, click iOSProjectStarter project inside Project navigator, then inside targets double click iOSProjectStarterTests and rename it to iOSProjectStarterSpec.

Rename test target to spec

Unfortunately, this will not rename the directory with tests, we have to do this manually. Delete iOSProjectStarterTests from Project navigator:

Delete tests directory

Instead of deleting it, just Remove References.

Delete tests directory

Rename the directory in Finder:

Rename directory

Now drag and drop it into Project navigator:

Drag and drop specs directory

Don’t select Copy items if needed as files are already there. Just select appropriate target: iOSProjectStarterSpec.

Adding files

Now when you try to build project ⌘B, you should see an error:

Wrong path to plist file

That’s because in settings, there is an old path to Info.plist file which is linking to the old test directory. To change it simply open iOSProjectStarterSpec target and inside Build Settings look for Info.plist. Change the path from iOSProjectStarterTests to iOSProjectStarterSpec:

Change plist path

Right now you will be able to build the project, but there is a warning:

Plist warning

To fix it, go to target iOSProjectStarterSpec > Build Phases and remove Info.plist from Copy Bundle Resources section:

Remove plist file

And that’s all for this part, the project should compile without any warnings.

In the next step we will add additional libraries using Cocoapods.