This repository contains an iOS architecture documentation with a sample application that uses OMDb API and implements the Archit architecture.
-
You should enable Xcode Text Editing options:
- Line numbers. (Specify a line to a mate or search for a crash)
- Code folding ribbon. (Optional)
- Page guide at column: 140 (No line should exceed it, so we will all read the same code)
- Including whitespace-only lines. (Lighter files)
-
Create your application core framework:
Open Xcode and select File -> New -> Target...
Select Cocoa Touch Framework:
Configure your application core:
This core framework will include API clients, persistence... everything you need to reuse in the future, for example, in an application extension.
Remember provide protocols for every service or storage that you create, everything must work syncronous.
Don't import to the core framework anything related with UIKit or any other forbidden framework or dependency (pod) in an application extension. If you need it in the future, you can make an extension in the application target.
-
Create your application domain framework:
This domain framework will include domain models.
Don't import to the domain framework anything related with UIKit or any other forbidden framework or dependency (pod) in an application extension. If you need it in the future, you can make an extension in the application target.
-
Configure the schemes:
Edit all schemes:
For each scheme, enable "Gather Coverage Data" option and "Share" the scheme:
In the Breakpoint navigator, create an "Exception Breakpoint...":
And "Share Breakpoint":
Also create a "Symbolic Breakpoint..." with "UIViewAlertForUnsatisfiableConstraints" as "Symbol" and "Share Breakpoint":
We delegate all responsibilities of the AppDelegate to an AppManager under our control, testable and that will be in charge of initializing all third-party frameworks that need initialization in the didFinishLaunching for example.
In addition, if we need location services, notifications, etc. We will create independent managers for each of them, and only their implementation will have access to the specific frameworks.
We will create base view controllers for each of the native view controllers we need, all the application view controllers will inherit from these base view controllers.
Each view controller will be injected with the corresponding controller depending on whether we are developing, testing or in production, so we can mock what we want.
Each controller will have an interactor who will be in charge of calling the asynchronous core framework tasks, generating a Kommand and passing it to the controller for execution and response handling.
Only the StorageManager knows the existence of the persistence framework that is used.
There will be intermediate StorageModels to map/parse the application model and store/update/fetch them in the database.
Only the HTTPClient knows the existence of the networking framework that is used.
There will be intermediate NetworkModels to map/parse the application model and get/post/put them to the network.
The service has tasks for each network API call related with the same context (application model, use case, web service).
Every networking layer must be implemented around Net protocol.
By default, we'll use NetClient for networking.
We can use Kommander to manage asynchronous processes, but always outside the Core Framework.
To instantiate or reuse Storyboards, ViewControllers, Views, UITableViewCells or UICollectionViewCells, you must use Reusable.
To handle Dates and Timezones, we could use SwiftDate.
We MUST use ATTD with HonestCode, therefore we'll need Cucumberish.
In order to use user location, we will use IGZLocation.
When we need to modify Auto Layout programmatically, we could use SnapKit.
For async image loading we could use Kingfisher.
To use NotificationCenter, SwiftNotificationCenter is recommended.
To display the progress of an ongoing task, you could use SVProgressHUD or SkeletonView.
To securely store data, we use Valet.
As logging library, we love XCGLogger.
- Contributions are very welcome.
- Attribution is appreciated (let's spread the word!), but not mandatory.
alexruperez, [email protected]
Archit is available under the MIT license. See the LICENSE file for more info.