Skip to content

jihoonme/tuistui

Repository files navigation

header

GitHub

TuistUI is Style Plugin for cooler use of Tuist.

Installation

In order to tell Tuist you'd like to use TuistUI plugin in your project follow the instructions that are described in Tuist documentation.

Add the plugin to Config.swift.

import ProjectDescription

let config = Config(
    plugins: [
        .git(url: "https://github.com/jihoonme/tuistui", tag: "vTAG")
    ]
)

Documentation

The documentation for releases and main are available here:

Using

Then import the TuistUI from thr location you want to use.

import TuistUI

Creating Project with TuistUI

struct BaseFeature: Module {
    var body: some Module {
        Project {
            /// Target Code
        }
        .organizationName("")
        .package {
            /// Package Code
        }
    }
}

additional operations

let project = BaseFeature().module()

Creating Workspace with TuistUI

struct TuistApp: Module {
    var body: some Module {
        Workspace {
            Path.relativeToRoot("Projects/App")
        }
        .scheme {
            /// Scheme Code
        }
    }
}

additional operations

let workspace = TuistApp().module()

Environment management

EnvironmentObject can manage redundant parts of a project or workspace.

final class AppEnvironment: EnvironmentObject {
    let organizationName: String = ""
    let destinations: Destinations = .iOS
    let deploymentTargets: DeploymentTargets = .iOS("15.0")
}

How to use within a module.

struct BaseProject: Module {
    @ModuleEnvironment var env = AppEnvironment()

    var body: Module {
        Project {
            // Target
        }
        .organizationName(env.organizationName)
    }
}

Configuration management

Management configurations effectively using the XCConfig Protocol.

struct AppConfiguration: XCConfig {

    enum XCConfigTarget: String, XCConfigTargetType {
        case baseProject

        var path: Path {
            switch self {
            case .baseProject:
                return .relativeToRoot("XCConfig/baseProject")
            }
        }
    }

    var body: some XCConfigOf<Self> {
        Configure ({
            switch $0 {
            case .baseProject:
                return [
                    // Write Configuration Method
                ]
            }
        })
    }
}

Set the Deploy Target part of XCConfig.

enum XCConfigDeployTarget: String, XCConfigDeployTargetType {
    case dev = "DEV"
    case stage = "STAGE"
    case prod = "PROD"
} 

And use .debug(into:deploy:) method, .release(into:deploy:) method extended to ConfigurationName and make it easier to use

var body: some XCConfigOf<Self> {
    Configure ({
        switch $0 {
        case .A:
            return [
                .debug(into: $0, deploy: XCConfigDeployTarget.dev)
                .release(into: $0, deploy: XCConfigDeployTarget.prod)
            ]
        }
    })
}

How to use within a module.

struct BaseProject: Module {
    let config = AppConfiguration()

    var body: Module {
        Project {
            // Target
        }
        .settings(
            .settings(
                configurations: config.configure(into: .baseProject)
            )
        )
    }
}

Templates

It is designed to accelerate project creation and workspace creation with templates.

$ tuist scaffold $(templateName) --path $(path) --name $(name)
Template Name
  • project
  • workspace

Project Structure With TuistUI

Project File and Workplace File are gathered in one place to facilitate quick modifications.

Using Project Template

.
├── Projects
│   └── App
│     └── Project.swift //<- Project.swift file Generate
├── Tuist
│   ├── ProjectDescriptionHelpers
│     └── Projects
│       └── DemoProject.swift //<- DemoProject.swift file Generate
│   ├── Dependencies.swift
│   ├── Config.swift
│   └── Package.swift
└── README.md

Using Workspace Template

.
├── Projects
│   └── App
│     └── Workspace.swift //<- Workspace.swift file Generate
├── Tuist
│   ├── ProjectDescriptionHelpers
│     └── Workspace
│       └── DemoApp.swift //<- DemoApp.swift file Generate
│   ├── Dependencies.swift
│   ├── Config.swift
│   └── Package.swift
└── README.md

To modify the contents of a project and workspace, you only need to modify the ProjectDescription File, WorkspaceDescription File, which are clustered in the ProjectDescription Helper folder.

License

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