Configuration

We will start our application development using CocoaPods (https://cocoapods.org/). We can install it by executing the following command in the terminal:

sudo gem install cocoapods

Then, we will create a folder using Finder or simply execute the following command in the terminal:

mkdir Frontend

Next, we will create a Single View Application project in Xcode as shown in the following screenshot:

We are going to name it TodoApp and provide an organization name and identifier. The programming language is going to be Swift, and devices will be Universal. Now, we can close the project and go back to the terminal.

In the terminal, we will execute the following command:

cd Frontend/TodoApp 
pod init

This will create a file named Podfile. This is where we define our dependencies.

Uncomment the first and third line so it becomes as follows:

platform :ios, '9.0' 
use_frameworks!

target 'TodoApp' do
end

target 'TodoAppTests' do

end

Now, we need to define dependencies for our target. We can go to https://cocoapods.org/ and search for any dependency, copy the definition, and paste it into our Podfile:

platform :ios, '9.0' 
use_frameworks!

target 'TodoApp' do
pod 'Alamofire', '~> 4.0'
pod 'Argo'
pod 'Curry'
pod 'ReactiveCocoa', '~> 5.0.0'
pod 'Delta', :git => "https://github.com/conqueror/Delta.git"
end

target 'TodoAppTests' do

end

Now, we can save and close our Podfile and move on to the terminal application. In the terminal application, we will execute the following command:

pod install

This directive will create a workspace, download all dependencies, and link them as frameworks into our project. Now, we can open TodoApp.xcworkspace with Xcode.

In the workspace, we will see two projects: TodoApp and Pods. Pods will contain all the dependencies.

Next, let's create a folder hierarchy to organize our workspace. In the workspace, right-click on a folder and select Show In Finder. Here, we will create the following folders and files:

  • Actions
  • Communication
  • Controllers
  • Extensions
  • Managers
  • Models
  • Resources
  • State
  • Views

Next, we will add these folders to our project by right-clicking on the TodoApp folder and selecting Add Files to "TodoApp", as shown in the following screenshot:

At this point we can move ViewController to the Controllers folder and any images to the Resources folder.

When we are done with our application, the folder and file hierarchy will be as follows:

As an alternative, instead of manually creating folders, we can create our groups in Xcode and use SYNX (https://github.com/venmo/synx) to create folders that match our Xcode groups.

Since our backend does not comply with security policies (for example, cleartext HTTP resource load) enforced by Apple, we will need to set the NSAllowsArbitraryLoads key to YES under the NSAppTransportSecurity dictionary in our .plist file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset