Configuration File

Specify your architecture and directory layout.

Configuration file

Add a .mttm_config file at the root directory of your git repository. Mototomo will pick it up to know how to deal with your project.

You can define how components of your software can talk to each other. You can also ban some relations (e.g., a ViewController should never reference a Model in the MVVM pattern).

All the rules definining your architecture defines a rule array in the json file:

{
    "rules": [
        {
            "name": "ViewController",
            "pattern": "ViewController?$",
            "use": ["ViewModel"],
            "forbidden": ["Model"]
        },
        {
            "name": "ViewModel",
            "pattern": "ViewModel?$",
            "use": ["Model"]
        },
        {
            "name": "Model",
            "pattern": "Model?$"
        }
    ]
}

In this example we define three different kinds of entities: ViewController, ViewModel and Model. The pattern key is used to identify the classes or structs that belong to the group. You can then define the interactions between the groups with use and forbidden.

Code Organization

Mototomo expects a given disk layout; it wants a single xcworkspace or xcodeproj at the root directory of the git repo. If it is not the case, you’ll need to specify it in the config file.

Suppose that you have the following directory structure.

$ tree -L 2 OwlTimer
.
├── Project
│   ├── OwlTimer.xcodeproj
│   │   ├── project.pbxproj
│   │   └── project.xcworkspace
│   ├── OwlTimer.xcworkspace
│   ├── contents.xcworkspacedata
│   └── xcshareddata
│   ├── Assets.xcassets
│   ├── Decoration
│   ├── Info.plist
│   ├── Infrastructure
│   ├── OwlTimer.entitlements
│   ├── Presets
│   ├── Timing
│   ├── Views
│   ├── Web\ API
│   └── Recordings-MVVM-C
├── Webserver
│   ├── public
│   ├── readme.md
│   └── sinatra.rb
├── LICENSE
└── README.md

As you can see, the OwlTimer.xcworkspace is not at the root of the directory. Help mototomo to find it by specifying its relative path:

{ 
    file-to-analyse: "Project/OwlTimer.xcworkspace",
    rules: {
        // Your architecture definition
    }
}

This is a very simple but functional .mttm-config:

{
    "rules": [
        {
        "name": "ViewController",
        "pattern": "ViewController?$",
        "use": [
            "ViewModel",
            "ViewControllerDelegate",
            "Helpers"
        ],
        "forbidden": [
            "Model"
        ]
        },
        {
        "name": "ViewModel",
        "pattern": "ViewModel?$",
        "use": [
            "Model"
        ]
        },
        {
        "name": "Model",
        "pattern": "Model?$"
        },
        {
        "name": "Coordinator",
        "pattern": "Coordinator?$",
        "use": [
            "ViewControllerDelegate"
        ]
        },
        {
        "name": "ViewControllerDelegate",
        "pattern": "ViewControllerDelegate?$",
        },
        {
        "name": "Helpers",
        "pattern": "Helpers?$"
        }
    ]
}