Skip to content

Latest commit

 

History

History
701 lines (578 loc) · 17.2 KB

project-folder-structure.md

File metadata and controls

701 lines (578 loc) · 17.2 KB

iOS Project Folder Structure

Table of Contents

ProjectFolderTree

├── ProjectFolder

  ├── AppDelegate
    ├── AppDelegate.swift
    ├── AppDelegate+Firebase.swift
    ├── ...

  ├── Configuration
    ├── Release
      ├── -.plist
      ├── -.entitlements
      ├── sdk config files
    ├── Debug
      ├── -.plist
      ├── -.entitlements
      ├── sdk config files

  ├── Entity
    ├── Model
      ├── Object Files
    ├── Enum
      ├── Enum Files

  ├── Protocols
    ├── Protocol files

  ├── Validation
    ├── Constants
      ├── ValidationConstants.swift
    ├── Classes
      ├── Custom files
    ├── Rules
      ├── Rules files

  ├── EventManager
    ├── Core
      ├── Core event files
    ├── Firebase
      ├── FirebaseEventProvider files
    ├── OtherProvider
      ├── OtherProvider files

  ├── Constants
    ├── Constants.swift
    ├── Globals.swift
    ├── DefaultsKeys.swift
    ├── NotificationNames.swift
    ├── NotificationParameterKeys.swift
    ├── DateFormats.swift
    ├── Other Constants files

  ├── DeepLink
    ├── DeepLink classes

  ├── Singleton
    ├── Singleton classes

  ├── Routing
    ├── Core
      ├── Core classes
    ├── Animator
      ├── Animator classes
    ├── Routes
      ├── AppStoreRoute
      ├── AppSettingsRoute
      ├── Other global routes
    ├── Transitions
      ├── Transitions classes

  ├── Helper
    ├── Helper classes

  ├── Scenes
    ├── Auth
      ├── SignIn
        ├── SignInViewController.swift
        ├── SignInViewModel.swift
        ├── SignInRouter.swift
        ├── SignInRoute.swift
      ├── SignUp
        ├── SignInViewController.swift
        ├── SignInViewModel.swift
        ├── SignInRouter.swift
        ├── SignInRoute.swift
      ├── ForgotPassword
        ├── ForgotPasswordViewController.swift
        ├── ForgotPasswordViewModel.swift
        ├── ForgotPasswordRouter.swift
        ├── ForgotPasswordRoute.swift
    ├── Agreement
      ├── AgreementViewController.swift
      ├── AgreementViewModel.swift
      ├── AgreementRouter.swift
      ├── AgreementRoute.swift
    ├── SceneName
      ├── SceneNameViewController.swift
      ├── SceneNameViewModel.swift
      ├── SceneNameRouter.swift
      ├── SceneNameRoute.swift


├── Utilities

  ├── Extensions
    ├── UIImage+Extensions.swift
    ├── String+Extensions.swift
    ├── ...

  ├── Constants
    ├── Closures.swift
    ├── ...

  ├── Helper
    ├── KeyboardHelper.swift
    ├── ...


├── UIComponents

  ├── Resources
    ├── Assets
      ├── Icons.xcassets
      ├── Images.xcassets
      ├── Colors.xcassets
      ├── Assets.swift
      ├── UIImage+Icons.swift
      ├── UIImage+Images.swift
      ├── UIColor+Colors.swift
    ├── Strings
      ├── General.strings
      ├── Error.strings
      ├── Placeholder.strings
      ├── Modules.strings
      ├── Components.strings
      ├── StringConstants.strings
    ├── Fonts
      ├── Fonts.swift
      ├── UIFont+Extensions.swift
      ├── Fonts files
    ├── Sounds
      ├── Sound files
    ├── Gif
      ├── Gif files

  ├── Extensions
    ├── UIImage+Extensions.swift
    ├── UICollection+Extensions.swift
    ├── ...

  ├── Protocol
    ├── ReusableView.swift
    ├── ...

  ├── UIButton
    ├── PrimaryButton.swift
    ├── ...

  ├── Builder
    ├── UILabelBuilder.swift
    ├── UIButtonBuilder.swift
    ├── ...

  ├── Cell
    ├── UserCell.swift
    ├── ProductCell.swift
    ├── ...


├── DataProvider

  ├── Core
    ├── Typealias.swift
    ├── RequestProtocol.swift
    ├── RequestMethod.swift
    ├── RequestEncoding.swift
    ├── DataProviderProtocol.swift
    ├── ...

  ├── Manager
    ├── DataManager.swift
    ├── ...

  ├── Entity
    ├── User
      ├── User.swift
      ├── Gender.swift
      ├── ...
    ├── Auth.swift
    ├── ...

  ├── Requests
    ├── User
      ├── GetUserRequest.swift
      ├── UpdateUserRequest.swift
      ├── ...
    ├── VersionControlRequest.swift
    ├── ...

Project

AppDelegate

Main AppDelegate should contain just default native functions. All 3rd party libraries should be separated from AppDelegate as extensions. Apart from that, Universal Link Handler & Push Notification Handler should also be separated as extensions. This distinction should be made in classic extension naming. Example -> (AppDelegate + {3rd party library name})
├── ProjectFolder
  ├── AppDelegate
    ├── AppDelegate.swift
    ├── AppDelegate+Firebase.swift
    ├── ...

Configuration

Configuration folder should contain entitlements, plist files, briding-header files, yml files(if available).They should divide into folders by build config.
├── ProjectFolder
  ├── Configuration
    ├── Release
      ├── -.plist
      ├── -.entitlements
      ├── sdk config files
    ├── Debug
      ├── -.plist
      ├── -.entitlements
      ├── sdk config files

Entity

It contains the models we create custom and the enums we need. As an example of custom models, models that we format the responses from web services by to specific logic.
├── ProjectFolder
  ├── Entity
    ├── Model
      ├── Object Files
    ├── Enum
      ├── Enum Files

Protocols

Multiple protocols used in App should store under the Protocols folder. These protocols should divided by their usage purpose such as AppleSignInProtocol, FacebookSignInProtocol.
├── ProjectFolder
  ├── Protocols
    ├── Protocol files

Validation

All validation files should store under the Validation folder. The core files and custom files should store under the Classes folder. If you are using custom rules, these rules should store under the Rules folder divided by their usage. All the constants such as password minimum - maximum length should store under the Constants folder with ValidationConstants.swift naming.
├── ProjectFolder
  ├── Validation
    ├── Constants
      ├── ValidationConstants.swift
    ├── Classes
      ├── Custom files
    ├── Rules
      ├── Rules files

EventManager

....
├── ProjectFolder
  ├── EventManager
    ├── Core
      ├── Core event files
    ├── Firebase
      ├── FirebaseEventProvider files
    ├── OtherProvider
      ├── OtherProvider files

Constants

All constants used in App should be stored under the Constants folder. Such as Globals.swift, NotificationKeys, UserDefaultsKeys, DateFormatter etc.

  • NotificationCenter

NotificationCenter extension file should be used, notification names NotificationNames.swift and notification parameters NotificationParameterKeys.swift named under Constants folder.

  • UserDefaults

MobilliumUserDefaults library should be used and defaults key should be stored under the Constants folder named as DefaultsKeys.swift.

  • DateFormatter

MobilliumDateFormatter library should be used, if need to use extension it should be named as DateFormats.swift and should be stored under the Constants folder.

├── ProjectFolder
  ├── Constants
    ├── Constants.swift
    ├── Globals.swift
    ├── DefaultsKeys.swift
    ├── NotificationNames.swift
    ├── NotificationParameterKeys.swift
    ├── DateFormats.swift
    ├── Other Constants files

DeepLink

DeepLink files should be stored under the **DeepLink** folder.
├── ProjectFolder
  ├── DeepLink
    ├── DeepLink classes

Singleton

Each singleton pattern which we need to use will keep under separated singleton classes and files, like AuthSingleton.swift, etc.
├── ProjectFolder
  ├── Singleton
    ├── Singleton classes

Routing

The router will be under the related modules.
├── ProjectFolder
  ├── Routing
    ├── Core
      ├── Core classes
    ├── Animator
      ├── Animator classes
    ├── Routes
      ├── AppStoreRoute
      ├── AppSettingsRoute
      ├── Other global routes
    ├── Transitions
      ├── Transitions classes

Helper

Helper should be divided into swift files according to their process rather than a general helper. For example FirebaseHelper.swift, StripeHelper.swift. Helpers should be under the **Helper** folder.
├── ProjectFolder
  ├── Helper
    ├── Helper classes

Scenes

Scenes should be divided under the **Scenes** folder. If a scene has flow for more than one scene it should be separated to another folder.
├── ProjectFolder
  ├── Scenes
    ├── Auth
      ├── SignIn
        ├── SignInViewController.swift
        ├── SignInViewModel.swift
        ├── SignInRouter.swift
        ├── SignInRoute.swift
      ├── SignUp
        ├── SignInViewController.swift
        ├── SignInViewModel.swift
        ├── SignInRouter.swift
        ├── SignInRoute.swift
      ├── ForgotPassword
        ├── ForgotPasswordViewController.swift
        ├── ForgotPasswordViewModel.swift
        ├── ForgotPasswordRouter.swift
        ├── ForgotPasswordRoute.swift
    ├── Agreement
      ├── AgreementViewController.swift
      ├── AgreementViewModel.swift
      ├── AgreementRouter.swift
      ├── AgreementRoute.swift
    ├── SceneName
      ├── SceneNameViewController.swift
      ├── SceneNameViewModel.swift
      ├── SceneNameRouter.swift
      ├── SceneNameRoute.swift

Utilities

Extensions

Extensions folder should contain all extensions except DataProvider extensions. Extension files should be separated by their classes and usage such as UIImage+Extensions.swift, String+Extensions.swift etc.

├── Utilities
  ├── Extensions
    ├── UIImage+Extensions.swift
    ├── String+Extensions.swift
    ├── ...

Constants

Constants folder should contain files such as Closures.swift and separated by their usage.

├── Utilities
  ├── Constants
    ├── Closures.swift
    ├── ...

Helper

Helper folder should contain files such as KeyboardHelper.swift and separated by their usage.

├── Utilities
  ├── Helper
    ├── KeyboardHelper.swift
    ├── ...

UIComponents

UIComponents should contain Resources, CustomViews and Builders. The files of the resources created with the SwiftGen will be here.

Resources

Folder containing files added externally to the project. Examples of these are Gif's, Animations, Assets, Sound Files, Strings, Font files.(Externally added .plist files are not included in this category.)
├── UIComponents

  ├── Resources
    ├── Assets
      ├── Icons.xcassets
      ├── Images.xcassets
      ├── Colors.xcassets
      ├── Assets.swift
      ├── UIImage+Icons.swift
      ├── UIImage+Images.swift
      ├── UIColor+Colors.swift
    ├── Strings
      ├── General.strings
      ├── Error.strings
      ├── Placeholder.strings
      ├── Modules.strings
      ├── Components.strings
      ├── StringConstants.strings
    ├── Fonts
      ├── Fonts.swift
      ├── UIFont+Extensions.swift
      ├── Fonts files
    ├── Sounds
      ├── Sound files
    ├── Gif
      ├── Gif files

Extensions

Each component extensions (FILE_NAME+Extension.swift) should be kept in a separate file and these files should be under the Extensions folder.
├── UIComponents

  ├── Extensions
    ├── UIImage+Extensions.swift
    ├── UICollection+Extensions.swift
    ├── ...

Protocol

Protocols should be under the Protocol folder.
├── UIComponents

  ├── Protocol
    ├── ReusableView.swift
    ├── ...

UIButton

Every custom button should be under UIButton folder.
├── UIComponents

  ├── UIButton
    ├── PrimaryButton.swift
    ├── ...

Builder

Builders for UIComponents should be kept in a separate file and these files should be under the Builder folder.
├── UIComponents

  ├── Builder
    ├── UILabelBuilder.swift
    ├── UIButtonBuilder.swift
    ├── ...

Cell

Every custom cell should be under Cell folder.
├── UIComponents

  ├── Cell
      ├── UserCell.swift
      ├── ProductCell.swift
      ├── ...

DataProvider

Core

Core folder should contains Protocols, Request Encodings and Typealiases related with DataProvider. If there is an extension needed on DataProvider it should store in DataProvider. The main aim is that DataProvider must not be depended other modules or app. It should work if it is extract from the main app.

├── DataProvider

  ├── Core
    ├── Typealias.swift
    ├── RequestProtocol.swift
    ├── RequestMethod.swift
    ├── RequestEncoding.swift
    ├── DataProviderProtocol.swift
    ├── ...

Manager

Manager should contains DataManager class which is a manager of all requests.

├── DataProvider

  ├── Manager
    ├── DataManager.swift
    ├── ...

Entity

Entity should contains an all object models of app. These models should separated by their relations and grouped by folders.

├── DataProvider

  ├── Entity
    ├── User
      ├── User.swift
      ├── Gender.swift
      ├── ...
    ├── Auth.swift
    ├── ...

Requests

Requests should contains an all Api requests of app. These requests should seperated by their relations and grouped by folders.

├── DataProvider

  ├── Requests
    ├── User
      ├── GetUserRequest.swift
      ├── UpdateUserRequest.swift
      ├── ...
    ├── VersionControlRequest.swift
    ├── ...