/
Project+Templates.stencil
74 lines (67 loc) · 3.05 KB
/
Project+Templates.stencil
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import ProjectDescription
/// Project helpers are functions that simplify the way you define your project.
/// Share code to create targets, settings, dependencies,
/// Create your own conventions, e.g: a func that makes sure all shared targets are "static frameworks"
/// See https://docs.tuist.io/guides/helpers/
extension Project {
/// Helper function to create the Project for this ExampleApp
public static func app(name: String, destinations: Destinations, additionalTargets: [String]) -> Project {
var targets = makeAppTargets(name: name,
destinations: destinations,
dependencies: additionalTargets.map { TargetDependency.target(name: $0) })
targets += additionalTargets.flatMap({ makeFrameworkTargets(name: $0, destinations: destinations) })
return Project(name: name,
organizationName: "tuist.io",
targets: targets)
}
// MARK: - Private
/// Helper function to create a framework target and an associated unit test target
private static func makeFrameworkTargets(name: String, destinations: Destinations) -> [Target] {
let sources = Target(name: name,
destinations: destinations,
product: .framework,
bundleId: "io.tuist.\(name)",
infoPlist: .default,
sources: ["Targets/\(name)/Sources/**"],
resources: [],
dependencies: [])
let tests = Target(name: "\(name)Tests",
destinations: destinations,
product: .unitTests,
bundleId: "io.tuist.\(name)Tests",
infoPlist: .default,
sources: ["Targets/\(name)/Tests/**"],
resources: [],
dependencies: [.target(name: name)])
return [sources, tests]
}
/// Helper function to create the application target and the unit test target.
private static func makeAppTargets(name: String, destinations: Destinations, dependencies: [TargetDependency]) -> [Target] {
let infoPlist: [String: Plist.Value] = [
"CFBundleShortVersionString": "1.0",
"CFBundleVersion": "1",
"UILaunchStoryboardName": "LaunchScreen"
]
let mainTarget = Target(
name: name,
destinations: destinations,
product: .app,
bundleId: "io.tuist.\(name)",
infoPlist: .extendingDefault(with: infoPlist),
sources: ["Targets/\(name)/Sources/**"],
resources: ["Targets/\(name)/Resources/**"],
dependencies: dependencies
)
let testTarget = Target(
name: "\(name)Tests",
destinations: destinations,
product: .unitTests,
bundleId: "io.tuist.\(name)Tests",
infoPlist: .default,
sources: ["Targets/\(name)/Tests/**"],
dependencies: [
.target(name: "\(name)")
])
return [mainTarget, testTarget]
}
}