Intelygenz iOS Architecture
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Archit.xcodeproj
Archit.xcworkspace
Archit
ArchitTests
ArchitUITests
Core
CoreTests
Domain
DomainTests
Pods
Resources
Scripts
fastlane
.gitignore
.swift-version
.swiftlint.yml
.travis.yml
CODE_OF_CONDUCT.md
Dangerfile
Gemfile
Gemfile.lock
ISSUE_TEMPLATE.md
LICENSE
Logo.png
PULL_REQUEST_TEMPLATE.md
Podfile
Podfile.lock
README.md
Rakefile
_config.yml

README.md

Intelygenz iOS Architecture

Twitter Build Status License codebeat badge

This repository contains an iOS architecture documentation with a sample application that uses OMDb API and implements the Archit architecture.

🔨 Xcode Configuration

  • You should enable Xcode Text Editing options:

    1. Line numbers. (Specify a line to a mate or search for a crash)
    2. Code folding ribbon. (Optional)
    3. Page guide at column: 140 (No line should exceed it, so we will all read the same code)
    4. Including whitespace-only lines. (Lighter files)

    Xcode Text Editing

🔧 Project Configuration

  • Create your application core framework:

    Open Xcode and select File -> New -> Target...

    New Target

    Select Cocoa Touch Framework:

    Cocoa Touch Framework

    Configure your application core:

    New 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:

    Edit Scheme

    For each scheme, enable "Gather Coverage Data" option and "Share" the scheme:

    Gather Coverage Data

    In the Breakpoint navigator, create an "Exception Breakpoint...":

    Exception Breakpoint

    And "Share Breakpoint":

    Share Breakpoint

    Also create a "Symbolic Breakpoint..." with "UIViewAlertForUnsatisfiableConstraints" as "Symbol" and "Share Breakpoint":

    Unsatisfiable Constraints Breakpoint

🤓 Usage

AppManager

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.

AppManager

VCI (ViewController Controller Interactor)

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.

VCI (ViewController Controller Interactor)

Core Framework

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).

Core Framework

CocoaPods

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.

❤️ Etc.

  • Contributions are very welcome.
  • Attribution is appreciated (let's spread the word!), but not mandatory.

👨🏻‍💻 Authors

alexruperez, alejandro.ruperez@intelygenz.com

👮🏻 License

Archit is available under the MIT license. See the LICENSE file for more info.