-
Book Overview & Buying
-
Table Of Contents
Swift Cookbook
By :
Usually, starting Swift is something that is very straightforward; however, it is good to know what is going on in every step.
Before you start a project, make sure that you know your project name and in which folder it will be saved. Changing this kind of parameter can create problems after the project has been created. Once you have Xcode installed, you can open it from your application folder, from the Launch pad, or even from your dock if you have added Xcode on it. As I'm a very lazy person, I prefer the latter; it's faster for me to have it on my dock.
The first time you open Xcode, it's possible that it will ask to install some additional packages, so do it. Some of these packages are important, depending on the type of application you are developing, and some of them are necessary to have access for some devices, mainly the newest ones.

If, for any reason, this window is not shown to you, there is always the option to go to File (on the menu bar) | New | Project.

The next dialog will ask you for some project information, one example being the programming language that you want to use. In this example, we will use Swift.

You will also notice that Swift iOS applications now have no files called main.m, main.mm, or main.swift. OS X apps have a main.swift file, but it is smaller than the previous main.m file.
As you should already know, the product name is your application name, the organization name is the proprietary of this software, and the organization identifier is the reversed Internet domain, for example, uk.co.packtpub instead of packtpub.co.uk.


Creating a project is not something difficult; you only need to pay attention at some steps. Make sure that you have selected Swift as the main programming language; otherwise, you will see a lot of stuff with Objective-C.
Pay attention to the folder where you will create your project. Xcode will create another folder with your project name, and inside of it, Xcode will create the project bundle, a folder with the source code. If you want to copy your project, make sure that you copy the folder that contains everything.
If you want to work on a team that already started a project, you probably will clone the project using the Check out an existing project option. You will use a Git or a subversion repository, and you will have your code synchronized with the other members of the team. Xcode offers us the basic tools to work with a VCS (version control system); these are enough for 80 percent of our tasks.
Change the font size
Change margin width
Change background colour