Lesson 2 - Project Structure and Organization

This lesson shows you how to create a new iOS project with Xcode.

Activity Type Lesson
Expected duration 30 minutes
Topic iOS project Structure and organization.
Objective Get to know the basic files of an iOS project.


  1. Generated files and its functions

We are going to talk about the files generated when you select an application of one view. The type of application that was created in the first lesson.

The first file and maybe one of the most important for the application is the AppDelegate. This file is the one in charge to inform the developer any change in the life cycle of the application, so he or she can execute actions inherent to a specific situation.

For example, the most commonly used method is the one named "application did finish launching", this method is called when the application open for the first time after is downloaded or closed in the iPhone/iPad processes.

The next generated file is the ViewController, this is the one that contains the implementation of the controller for the main view. The classes that extends the UIViewController have methods of the life cycle of the view (not of the application), like: viewDidLoad, viewWillAppear, viewDidAppear, viewWillDisappear, etc. In this methods, we can configure the view or let go resources in case that the view is going to be closed or hidden.

The Main.storyboard is the main graphic interface of the app. This file models the user's desired flow in which each of the controllers has an associated class (ViewController.swift). When you select single view application template, Xcode generates a ViewController inside the story board which is connected to the ViewController.swift Class. This is the root view controller as you can tell by the left arrow pointing to the view in the storyboard. This means that when you run the app this will be the first view the user sees (after the splash screen).

In the storyboard you can change the resolution in which the views are rendered, by simply changing the “View as:” value. You can click on it and choose one of the available devices. To check how your app will be displayed on various iOS devices. The buttons of the bottom right corner correspond to the use of constrains, but we will not explain in this lesson how they work. Keep in mind that without constraints your app will always render in the size your storyboard is in. If you have your storyboard set to iPhone 6, without constraints, your app will try to render as iPhone 6 which can lead to unexpected behavior if used on any other device. We recommend you see the videos mentioned at the beginning regarding these buttons. Constraints can be tricky but when understood are very powerful, we invite you to play around and see what happens when yo use different constraints.

The next folder is called Assets.xcassets, this folder contains the images and icons of the application. iOS has three possible image sizes: normal (image.png), retina (image@2x.png), and highest resolution (image@3x.png). It is important that the bigger images have the double or triple of the normal size respectively. iOS uses these files dynamically to select the best looking asset for a given display. There are 2 approaches you can take to produce these files:

  1. You can use a tool like Prepo21 which helps you produce each of the resolutions necessary given a base asset.
  2. You can use PDF as assets for iOS. If you drag and drop a PDF into the Assets.xcassets, Xcode will render the PDF in the necessary sizes. For more information: Asset Catalog Changes in Xcode 9

Inside this folder, you will see something called “AppIcon”, there you must add the icons for your app, notification icon (for iPhone and iPad), settings icon and spotlight. Each icon has an specific size but you can use MakeAppIcon to generate all the icons and save time.

The next file is the LaunchScreen.storyboard, this file is similar to the storyboard explained before, but it handles only one file: the splash screen. iOS uses these files to quickly display something to the user. Apple’s guidelines suggest that you display some UI elements that are similar to the first screen of your app, this will give the impression of a faster loading time in your app. (i.e: Mail app in iOS has a splash screen just like the main view but without any email)

Finally there is the Info.plist, this is the configuration file of the app. Here you can modify the supported orientations and many other configurations. This file is the core guide for your app, everything your app needs to find, ask, save is configured here. We will look into this file in later guides but keep in mind this is were you setup permissions needed, external files used and other configurations for your app inside the iOS ecosystem.

Version Author Date
1.0 Sergio Yodeb Velasquez Yepes February 28, 2018
1.1 Laura Natalia Bello Jimenez January 26, 2019

For academic use exclusively.

results matching ""

    No results matching ""