Skip to content

ricardopsantos/RJPS_SwiftUIArchitecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter

Abstract

SmartApp is a template iOS application built with SwiftUI using MVVM and inspired by iOSKickstart: Create iOS App Boilerplate in Just 20 Seconds and the navigation was inspired by Modular Navigation in SwiftUI: A Comprehensive Guide.

Index

  • About: Into | Architecture Overview | Additional Modules | Dependencies Manager
  • Architecture: Application | Domain | Core | Common | DesignSystem | DevTools
  • Tests: UI Tests | Unit Tests
  • Misc: Design Language | XcodeGen | SwiftLint and SwiftFormat | Profiling | Install

About

Intro

SmartApp is a template iOS application built with SwiftUI using MVVM, and was mainly designed to serve as a template while integrating various frameworks and features in a well-organized structure with support for Unit Testing, UI Testing. Also makes use of other tools like XcodeGen, SwiftLint and SwiftFormat

SwiftUI because is Apple's current standart and offers several advantages like including a declarative syntax that simplifies UI design, real-time previews for faster iteration, and seamless integration with Swift for a unified coding experience while also enabling cross-platform development with a single codebase, significantly reducing development time and effort.

MVVM (Model-View-ViewModel) because separates concerns by dividing code into Model, View, and ViewModel, making maintenance easier. Also improves testability by isolating the ViewModel for unit tests, enhancing code reliability. It also boosts reusability, allowing ViewModels and Views to be used across different contexts. Additionally, MVVM simplifies data binding, integrating smoothly with SwiftUI and Combine for reactive and responsive user interfaces.

Architecture Overview

The app is built using Clean Architecture principles and separation of concerns, ensuring a maintainable and scalable codebase. It leverages dependency injection and interfaces for easy testing and seamless implementation changes.

  • SmartApp: The main application containing Views, ViewModels, Managers (e.g., Analytics), Assets, and handling the app's life cycle.

  • Domain: Defines the app's Models and Interfaces.

  • Core: Implements the business logic, such as caching and API requests, defined in the Domain.

  • DesignSystem: Houses definitions for the app's Fonts, Colors, and Designables (reusable UI components).

Additional Modules

There are 2 other modules not displayed for simplicity.

  • Common: A utility toolbox containing helper extensions, property wrappers, and other utilities. It has its own unit tests and can be used in any project as it has no dependencies.

  • DevTools: Manages app logs, with dependencies across all other modules to facilitate logging.

This modular structure ensures each component is focused on a specific responsibility, promoting clean, efficient, and easily testable code.

Dependencies Manager

Swift Package Manager simplifies dependency management and project organization for Swift developers. It enables you to easily add, update, and manage third-party libraries and frameworks. Integrated seamlessly with Xcode, Swift Package Manager promotes modularity, improves build performance, and ensures that your dependencies are up-to-date, making it an essential tool for modern Swift development.

Our philosophy emphasizes avoiding the addition of large dependencies for simple tasks (e.g., using Alamofire for a basic REST GET method). Instead, we carefully selected only three essential dependencies to handle complex or time-consuming (to implement) tasks:

  • Firebase: Integrated for various backend services, including authentication, real-time database, messaging, and analytics.
  • Nimble: A matcher framework that enables writing expressive and readable tests.
  • Reachability: A library used to monitor network reachability and handle network state changes effectively.

Architecture

The project is organized into several key directories/targets, each serving a specific purpose: SmartApp, Domain, Core, Common, DesignSystem, DevTools, SmartAppUnitTests, SmartAppUITests

Application

It's the main application target. Contains the Views (scenes), ViewModels (glue betweeen Views and Logic), Coordinators (routing logic).

Domain

This target encapsulates the interface functionality of the application. Providing the Models and Protocols it define what the app can do and the data structures to do it.

  • Repositories: Local data storage protocols.
  • Services: Bigde betweens ViewModels and Network and where we can have more logic associated (eg. caching)

Core

This target implements the Domain functionalities, providing essential components such as:

  • Network: Remote communication implementations.
  • Repositories: Local data storage implementations.
  • Services: Bigde betweens ViewModels and Network and where we can have more logic associated (eg. caching)

Notably, Services, Repositories and Network are defined and implemented via protocols. The actual implementation is determined in the main app target, which is crucial for testing and ensuring scalable, maintainable code.

Common

A shared framework that includes extensions and utility functions used across multiple targets, promoting code reuse and modularity. Should not depend on any target, and should seamless work on any project.

DesignSystem

This target houses design-related components, ensuring a consistent and reusable visual style throughout the application. Also houses the applications Colors and Fonts

DevTools

Includes various development tools and utilities such as logging, facilitating smoother development and debugging processes.

Tests

The app includes comprehensive testing coverage with both UI Tests and Unit Tests. These tests are designed to cover a wide range of daily development scenarios, ensuring the app's reliability and performance. Additionally, we have incorporated measure/performance tests to monitor and optimize the app's efficiency.

This revision aims to clearly communicate the purpose and scope of the tests while emphasizing their importance in maintaining app quality and performance.

UITesting

The app includes UI Tests for views and routing logic

Unit Testing (ViewModels & Services)

The app ViewModels are built on a way that can be tested.

The app Services are built on a way that can be tested.

Misc

Design Language

Design language in mobile apps refers to a set of guidelines and principles that define the visual and interactive style of an application. It includes elements like color schemes, typography, iconography, and spacing to ensure a cohesive and intuitive user experience. A well-defined design language helps maintain consistency, improve usability, and strengthen brand identity across different platforms and devices.

More about at Adding a Design Language to your Xcode project.

Custom Colors (for Ligth/Dark mode)

Custom Fonts

Custom Designables

XcodeGen

XcodeGen treamlines project management by allowing you to generate Xcode project files from a simple YAML or JSON specification. This approach reduces merge conflicts, ensures consistency across teams, and makes it easier to version control project settings. By automating project setup, XcodeGen enhances productivity and maintains a cleaner, more organized codebase.

SwiftLint and SwiftFormat

SwiftLint and SwiftFormat are essential tools for maintaining code quality in Swift projects. SwiftLint enforces coding style and conventions by analyzing your code for potential issues and inconsistencies, ensuring adherence to best practices. SwiftFormat, on the other hand, automatically formats your Swift code to conform to a consistent style, making it more readable and maintainable. Together, they help streamline development workflows and uphold code standards across teams.

Profiling

At the present day the project is leaks free.

Install

No need to install anything, as all app dependencies are managed via Swift Package Manager.

However, the project can be fully rebuilt with ./makefile.sh (for a total cleanup and conflict fixing) using XcodeGen. If you are not familiar with XcodeGen, please check Avoiding merge conflicts with XcodeGen.

The scripts can be found at SmartApp/XcodeGen.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages