Last active
October 7, 2022 12:38
-
-
Save alexdremov/cd2e7aedb2753b1db76a86b3ad6292b7 to your computer and use it in GitHub Desktop.
Tuist example project snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Target { | |
static func feature( | |
interface featureName: Feature, | |
dependencies: [ProjectDescription.TargetDependency] = [], | |
resources: ProjectDescription.ResourceFileElements? = [] | |
) -> Target { | |
.makeFramework( | |
name: featureName.rawValue + "Interface", | |
sources: [ "interface/**" ], | |
dependencies: dependencies, | |
resources: resources | |
) | |
} | |
static func feature( | |
interface featureName: Feature, | |
dependencies: [ProjectDescription.TargetDependency] = [], | |
resources: ProjectDescription.ResourceFileElements? = [] | |
) -> Target { | |
.makeFramework( | |
name: featureName.rawValue, | |
sources: [ "src/**" ], | |
dependencies: dependencies, | |
resources: resources | |
) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Target { | |
static func makeApp( | |
name: String, | |
sources: ProjectDescription.SourceFilesList, | |
dependencies: [ProjectDescription.TargetDependency] | |
) -> Target { | |
Target( | |
name: name, | |
platform: .iOS, | |
product: .app, | |
bundleId: makeBundleID(with: "app"), | |
deploymentTarget: .iOS(targetVersion: "16.0", devices: .iphone), | |
sources: sources, | |
dependencies: dependencies | |
) | |
} | |
} | |
let project = Project( | |
name: "ExampleApp", | |
targets: [ | |
.makeApp( | |
name: "ExampleApp", | |
sources: [ | |
"src/**" | |
], | |
dependencies: [ | |
.common, | |
.feature(implementation: .Foo), | |
.feature(interface: .Foo), | |
.feature(implementation: .Biz), | |
.feature(interface: .Biz), | |
.external(.FoggyColors) | |
] | |
) | |
] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Target { | |
static func makeFramework( | |
name: String, | |
sources: ProjectDescription.SourceFilesList, | |
dependencies: [ProjectDescription.TargetDependency] = [], | |
resources: ProjectDescription.ResourceFileElements? = [] | |
) -> Target { | |
Target( | |
name: name, | |
platform: .iOS, | |
product: defaultPackageType, | |
bundleId: makeBundleID(with: name + ".framework"), | |
sources: sources, | |
resources: resources, | |
dependencies: dependencies | |
) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Interface | |
public protocol NumberProvider { | |
var number: Int { get } | |
} | |
// Implementation | |
public struct NumberProviderZero: NumberProvider { | |
public let number = 0 | |
public init() { | |
} | |
} | |
public struct NumberProviderRandom: NumberProvider { | |
private let range: ClosedRange<Int> | |
public var number: Int { | |
Int.random(in: range) | |
} | |
public init(range: ClosedRange<Int>) { | |
self.range = range | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ProjectDescription | |
import ProjectDescriptionHelpers | |
let project = Project( | |
name: Feature.Foo.rawValue, | |
targets: [ | |
.feature( | |
implementation: .Foo, | |
dependencies: [ | |
.feature(interface: .Biz), | |
.external(.AsyncAlgorithms) | |
] | |
), | |
.feature( | |
interface: .Foo, | |
dependencies: [ | |
.feature(interface: .Biz) | |
] | |
) | |
] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Your project root | |
├── Workspace.swift | |
├── Tuist | |
│ ├── Config.swift | |
│ ├── Dependencies.swift | |
│ └── ProjectDescriptionHelpers | |
│ └── <tuist helpers> | |
└── modules | |
├── Foo | |
│ ├── Project.swift | |
│ └── <module code, folders> | |
├── Biz | |
│ ├── Project.swift | |
│ └── <module code, folders> | |
└── ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ProjectDescription | |
import ProjectDescriptionHelpers | |
let project = Project( | |
name: "ProjectName", | |
targets: [ | |
... | |
] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Your project root | |
├── Workspace.swift | |
├── Tuist | |
│ ├── Config.swift | |
│ ├── Dependencies.swift | |
│ └── ProjectDescriptionHelpers | |
│ └── <tuist helpers> | |
└── modules | |
├── Foo | |
│ └── Project.swift | |
│ ├── interface | |
│ │ └── <interface files> | |
│ └── src | |
│ └── <implementation files> | |
├── Biz | |
│ └── Project.swift | |
│ ├── interface | |
│ │ └── <interface files> | |
│ └── src | |
│ └── <implementation files> | |
└── ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct RandomScreenSimple: RandomScreen { | |
let randomProvider: NumberProvider | |
@State var number: Int = 0 | |
public init(randomProvider: NumberProvider) { | |
self.randomProvider = randomProvider | |
} | |
public var body: some View { | |
VStack { | |
Text("\(number)") | |
Button("generate") { | |
number = randomProvider.number | |
} | |
}.onAppear { | |
number = randomProvider.number | |
} | |
.animation(.default, value: number) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ProjectDescription | |
let workspace = Workspace( | |
name: "ExampleWorkspace", | |
projects: [ | |
"modules/*" | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment