Project Structure for iOS App Development
Hi everyone! Today I want to tell you about project structure and tools which I am using in iOS App Development. This is series of two articles which can help you with initial project setup. The first article will be about Project Structure.
Several weeks ago I start a new iOS App Development for one of our old product. We want to redesign, refresh our brand and create better user experience. So we decide to write iOS App from scratch (previously the App was developed by another person with help of crossplatform solutions). We choose Swift as main language for development (in my practice this is the first commercial App written with Swift language).
So what tools I choose to help me in development process? What project structure I choose? And even what architecture solution I choose (spoiler for next article:])?
Today I want answer on the first two questions. So let’s get started!
Project structure is important in any development. With good project structure you can easily find your classes, resources and other informations. So what is my way?
In root folder I have three folders.
- ci — folder with Continuous Integration scripts. We are using Bamboo by Atlassian for Continuous Integration and GitLab as version control system. We have three environments — testing, staging and production. Testing used for development, staging for finalizing versions and APIs and production is current Apps in AppStore. Our scripts upload builds to our own server to distribute Apps for testing over the air. Also we have Telegram bot for notifications. Each time new version was build we notify testers about this.
- TestProject is the main folder for Xcode Project.
- Tools folder contains help resources and scripts for developement. Here we have folders for Certificates and Provision Profiles, icons for AppStore, scripts for localisations (to validate localization strings and localize non localized strings). Also I have a folder for .paw file. Paw (https://paw.cloud) — cool MacOS App for testing server requests so I can easily test any server API request.
Go deep to Xcode project folder:
We are using CocoaPods as Dependency Manager. You just need to initialize project with
pod init command and then add dependencies to Podfile. Then call
pod install and CocoaPods download library and manage dependencies. That’s all! Very easy:] Please note: you must open *.xcworkspace file to edit and run your project.
Ok, let’s go deeper:
Let’s describe each folder:
- CustomControls — this is folder for any custom elements I develop from scratch. I am trying to make them as modules so I can easily copy paste them to another project and use them. Here I have folders like Cells (custom prototype cells seperateed by scenes), Extensions (custom extensions) and Views (custom views).
- Models — in this folder I store models which are used across App. Nothing special:]
- Resources — here is two folders: Storyboards and Assets.xcassets (also here is can be another folders like Fonts, Videos etc.). I try to seperate Storyboards and Image Assets by scenes. For example I have Storyboards Unboarding, AccountSettings etc. The same for Image Assets.
- Scenes — a home for UIViewControllers. I separate Scenes folder by logical modules. For example I have subfolders AccountSettings, LeftMenu, Unboarding etc. In each module I have actual folders for UIViewControllers. For example let’s look on Unboarding Scene module:
In Unboarding module folder I have scenes for each separate UIViewController. Also in each scene folder may be sub folders like SubControls (for custom views for this scene) and other.
- SupportingFiles — contains only AppDelegate and Info.plist file. Nothing special.
- Vendors — here is custom libraries or components which are not distributed over CocoaPods (or event our own frameworks which are developed as separate projects).
- Workers — this is our “logic” folder. Here is workers for getting data from server, from database, caching, sorting items etc.. Any logic with models works in this folder. Also this folder can contain subfolders like Helpers (any helper classes for example for animations, errors handling etc..), NetworkLayer (to send requests/get responses from server, authorize users and any other interactions with our server).
So I described our project structure for our new iOS Application. Let’s continue with Xcode Integrated Tools.
Read about Xcode Integrate Tools in my next article here https://medium.com/@vsemenchenko/xcode-integrated-tools-for-ios-app-development-3e930a743a17
Feel free about commenting and sending your feedback. Will be cool to discuss another approach for Project Structure. Thank you for reading!
P.S. Cool song which I found recently: Marillion — Story from a Thin Wall https://itun.es/ru/W2jvP?i=693411284