Tuist is a great tool to manage Swift projects.
But I still have to write a lot of codes to config my project.
So I decide to share my configuration. SwiftUItemplate is my opionionated configuration for Tuist.
tuist init --platform iosTuist/Config.swift, change it toimport ProjectDescription
let config = Config(
plugins: [
.git(url: "https://github.com/haifengkao/SwiftUITemplate", tag: "0.5.0")
]
)
tuist fetch in terminal to download SwiftUITemplateIf the above procedure doesn't work, please check Tuist documentation for more info.
SwiftUITemplate follows microfeature architecture.
An app is composed by mutiple microfeatures. Each microfeature contains
A module might be microfeature or a swift package (Cocoapods and Carthage are not supported, PR welcome).
To add a microfeature, create Tuist/ProjectDescriptionHelpers/Modules.swift.
Then add the microfeature to modules, e.g.
import ProjectDescription
import SwiftUITemplate
private extension Module {
static var MyApp: Module {
.uFeature(name: "MyApp", targets: [
.exampleApp: .resourcesOnly,
.unitTests: .default,
.framework: .default,
])
}
}
public let modules: [Module] = [
Module.MyApp,
Module.Quick,
Module.Nimble,
]
You can specify 4 different kinds of targets:
.framework the framework codes which other modules can depend on.unitTests the unit test target to test the framework.exampleApp the example target.uiTests the ui test target which will run over example appTargetConfig has four modes
.default indicates the target has no resources to include and no dependencies to other modules.resourcesOnly indicates the target has resources but no dependencies.hasDependencies([Modules]) let you specify the target's dependencies.hasResourcesAndDependencies([Modules]) indicates the target has resources and dependenciesBy default, SwiftUITemplate uses Nimble and Quick as the unit test framework. It's mandatory to include Nimble and Quick for the unit test placeholder codes to compile
You can specify project name and the targets in Project.swift.
import ProjectDescription
import ProjectDescriptionHelpers
import SwiftUITemplate
let project: Project = Project(name: "MyApp",
organizationName: "example.SwiftUITemplate",
targets: modules.allProjectTargets)
modules.allProjectTargets tells tuist to include all targets(exampleApp, unit test, frameworks) into the generated project.
To include swift packages, we can create a swift package with .package.
The following example adds Alamofire into MyApp's framework traget.
import ProjectDescription
import SwiftUITemplate
private extension Module {
static var MyApp: Module {
.uFeature(name: "MyApp", targets: [
.exampleApp: .resourcesOnly,
.unitTests: .default,
.framework: .hasDependencies([
.Alamofire
]),
])
}
static var Alamofire: Module {
.package(name: "Alamofire", url: "https://github.com/Alamofire/Alamofire", requirement: .upToNextMajor(from: "5.5.0"))
}
}
public let modules: [Module] = [
Module.MyApp,
Module.Quick,
Module.Nimble,
]
We don't have to add Module.Alamofire into modules because SwiftUITemplate will automatically find Module.Alamofire in Module.MyApp's dependencies.
Tuist requires us to specify swift packages in Dependencies.swift.
So we have to create Tuist/Dependencies.swift with the following content
import ProjectDescription
import ProjectDescriptionHelpers
import SwiftUITemplate
let dependencies = Dependencies(
swiftPackageManager: .init(
modules.allSwiftPacakges,
targetSettings: modules.allTargetSettings
),
platforms: [.iOS]
)
SwiftUITemplate will find out all swift packages defined in modules and its dependencies.
To generate the .xcworkspace
tuist fetch to download swift packagestuist generate to generate xcworkspaceIf the above procedure doesn't work, please check Tuist tutorial for more info.
├── Tuist
│ └── (Tuist setting files)
└── Features
├── MyApp
│ ├── Example (example target codes)
│ ├── Tests (unit test target codes)
│ └── Sources (framework codes)
└── MyFeature1
├── Example
├── Tests
└── Sources
All features are located in Features folder. SwiftUITemplate will find corresponding codes and resources in the predefined subfolders.
This plugin provides templates to create a microfeature placeholder files
tuist scaffold ufeature --name MyFeature1 --company TuistDemo
It will create MyFeature1 in Features folder.
A LLM generated wiki
I am too lazy to write a complete doc
To start working on the project, you can follow the steps below:
fixtures/Example1tuist fetch to install the plugintuist edit to modify the plugin filestuist generate to generate the example xcworkspace. Use this command to check if the plugin works correctly61 commits
Swift
95.0%
Python
5.0%
Tuist is a great tool to manage Swift projects.
But I still have to write a lot of codes to config my project.
So I decide to share my configuration. SwiftUItemplate is my opionionated configuration for Tuist.
tuist init --platform iosTuist/Config.swift, change it toimport ProjectDescription
let config = Config(
plugins: [
.git(url: "https://github.com/haifengkao/SwiftUITemplate", tag: "0.5.0")
]
)
tuist fetch in terminal to download SwiftUITemplateIf the above procedure doesn't work, please check Tuist documentation for more info.
SwiftUITemplate follows microfeature architecture.
An app is composed by mutiple microfeatures. Each microfeature contains
A module might be microfeature or a swift package (Cocoapods and Carthage are not supported, PR welcome).
To add a microfeature, create Tuist/ProjectDescriptionHelpers/Modules.swift.
Then add the microfeature to modules, e.g.
import ProjectDescription
import SwiftUITemplate
private extension Module {
static var MyApp: Module {
.uFeature(name: "MyApp", targets: [
.exampleApp: .resourcesOnly,
.unitTests: .default,
.framework: .default,
])
}
}
public let modules: [Module] = [
Module.MyApp,
Module.Quick,
Module.Nimble,
]
You can specify 4 different kinds of targets:
.framework the framework codes which other modules can depend on.unitTests the unit test target to test the framework.exampleApp the example target.uiTests the ui test target which will run over example appTargetConfig has four modes
.default indicates the target has no resources to include and no dependencies to other modules.resourcesOnly indicates the target has resources but no dependencies.hasDependencies([Modules]) let you specify the target's dependencies.hasResourcesAndDependencies([Modules]) indicates the target has resources and dependenciesBy default, SwiftUITemplate uses Nimble and Quick as the unit test framework. It's mandatory to include Nimble and Quick for the unit test placeholder codes to compile
You can specify project name and the targets in Project.swift.
import ProjectDescription
import ProjectDescriptionHelpers
import SwiftUITemplate
let project: Project = Project(name: "MyApp",
organizationName: "example.SwiftUITemplate",
targets: modules.allProjectTargets)
modules.allProjectTargets tells tuist to include all targets(exampleApp, unit test, frameworks) into the generated project.
To include swift packages, we can create a swift package with .package.
The following example adds Alamofire into MyApp's framework traget.
import ProjectDescription
import SwiftUITemplate
private extension Module {
static var MyApp: Module {
.uFeature(name: "MyApp", targets: [
.exampleApp: .resourcesOnly,
.unitTests: .default,
.framework: .hasDependencies([
.Alamofire
]),
])
}
static var Alamofire: Module {
.package(name: "Alamofire", url: "https://github.com/Alamofire/Alamofire", requirement: .upToNextMajor(from: "5.5.0"))
}
}
public let modules: [Module] = [
Module.MyApp,
Module.Quick,
Module.Nimble,
]
We don't have to add Module.Alamofire into modules because SwiftUITemplate will automatically find Module.Alamofire in Module.MyApp's dependencies.
Tuist requires us to specify swift packages in Dependencies.swift.
So we have to create Tuist/Dependencies.swift with the following content
import ProjectDescription
import ProjectDescriptionHelpers
import SwiftUITemplate
let dependencies = Dependencies(
swiftPackageManager: .init(
modules.allSwiftPacakges,
targetSettings: modules.allTargetSettings
),
platforms: [.iOS]
)
SwiftUITemplate will find out all swift packages defined in modules and its dependencies.
To generate the .xcworkspace
tuist fetch to download swift packagestuist generate to generate xcworkspaceIf the above procedure doesn't work, please check Tuist tutorial for more info.
├── Tuist
│ └── (Tuist setting files)
└── Features
├── MyApp
│ ├── Example (example target codes)
│ ├── Tests (unit test target codes)
│ └── Sources (framework codes)
└── MyFeature1
├── Example
├── Tests
└── Sources
All features are located in Features folder. SwiftUITemplate will find corresponding codes and resources in the predefined subfolders.
This plugin provides templates to create a microfeature placeholder files
tuist scaffold ufeature --name MyFeature1 --company TuistDemo
It will create MyFeature1 in Features folder.
A LLM generated wiki
I am too lazy to write a complete doc
To start working on the project, you can follow the steps below:
fixtures/Example1tuist fetch to install the plugintuist edit to modify the plugin filestuist generate to generate the example xcworkspace. Use this command to check if the plugin works correctly61 commits
Swift
95.0%
Python
5.0%