-
Notifications
You must be signed in to change notification settings - Fork 3
/
Project.swift
218 lines (205 loc) · 6.36 KB
/
Project.swift
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import ProjectDescription
import ProjectDescriptionHelpers
import MyPlugin
// Local plugin loaded
let localHelper = LocalHelper(name: "MyPlugin")
// MARK: - Project String Data
enum Ticlemoa: String {
static let projectName = "Ticlemoa"
static let productName = "Ticlemoa"
static let organizationName = "nyongnyong"
static let bundleId = "com.nyongnyong"
static let deploymentTarget = DeploymentTarget
.iOS(targetVersion: "15.0", devices: [.iphone])
case userInterface = "UserInterface"
case domainInterface = "DomainInterface"
case domain = "Domain"
case api = "API"
// case share = "ShareExtension"
var name: String { self.rawValue }
var product: Product {
switch self {
// case .share: return .appExtension
default: return .framework
}
}
}
// MARK: - Module
func interface(_ module: Ticlemoa,
infoPlist: InfoPlist? = nil,
dependencies: [Ticlemoa]
) -> [Target] {
return [
Target(
name: module.name,
platform: .iOS,
product: module.product,
bundleId: "\(Ticlemoa.bundleId).\(Ticlemoa.projectName).\(module.name)",
deploymentTarget: Ticlemoa.deploymentTarget,
infoPlist: infoPlist ?? .default,
sources: ["Targets/\(module.name)/Sources/**"],
dependencies: dependencies.map { .target(name: $0.name) }
)
]
}
func makeModule(_ module: Ticlemoa,
infoPlist: InfoPlist? = nil,
dependencies: [TargetDependency],
hasTest: Bool
) -> [Target] {
let sources = Target(
name: module.name,
platform: .iOS,
product: module.product,
bundleId: "\(Ticlemoa.bundleId).\(Ticlemoa.projectName).\(module.name)",
deploymentTarget: Ticlemoa.deploymentTarget,
infoPlist: infoPlist ?? .default,
sources: ["Targets/\(module.name)/Sources/**"],
resources: ["Targets/\(module.name)/Resources/**"],
dependencies: dependencies
)
if hasTest {
let tests = Target(
name: "\(module.name)Tests",
platform: .iOS,
product: .unitTests,
bundleId: "\(Ticlemoa.bundleId).DomainTests",
deploymentTarget: Ticlemoa.deploymentTarget,
infoPlist: .default,
sources: ["Targets/\(module.name)/Tests/**"],
resources: [],
dependencies: [
.target(name: module.name)
]
)
return [sources, tests]
} else {
return [sources]
}
}
// MARK: - Module
//let shareInfoPlist: InfoPlist = .extendingDefault(with: [
// "CFBundleDisplayName": "\(Ticlemoa.productName)",
// "CFBundleShortVersionString": "1.0.0",
// "NSExtension": [
// "NSExtensionPrincipalClass": "ShareExtension.ShareNavigationController",
// "NSExtensionAttributes": [
// "NSExtensionActivationSupportsText": true,
// "NSExtensionActivationRule": [
// "NSExtensionActivationSupportsWebURLWithMaxCount": 1,
// "NSExtensionActivationSupportsWebPageWithMaxCount": 1
// ]
// ],
// "NSExtensionPointIdentifier": "com.apple.share-services"
// ]
// ]
//)
let userInterface = makeModule(
.userInterface,
dependencies: [
.target(name: Ticlemoa.domainInterface.name),
// .external(name: "Collections")
],
hasTest: true
)
let api = makeModule(
.api,
dependencies: [],
hasTest: true
)
let domain = makeModule(
.domain,
dependencies: [
.target(name: Ticlemoa.api.name),
.target(name: Ticlemoa.domainInterface.name),
// .external(name: "KakaoSDK")
],
hasTest: true
)
//let share = makeModule(
// .share,
// infoPlist: shareInfoPlist,
// dependencies: [
// .target(name: Ticlemoa.userInterface.name),
// .target(name: Ticlemoa.domain.name)
// ],
// hasTest: false
//)
let domainInterface = makeModule(
.domainInterface,
dependencies: [],
hasTest: false
)
// MARK: - Project
let infoPlist: InfoPlist = .extendingDefault(with: [
"CFBundleShortVersionString": "1.0.0",
"CFBundleVersion": "1",
"UIMainStoryboardFile": "",
"UISupportedInterfaceOrientations" : ["UIInterfaceOrientationPortrait"],
"UILaunchStoryboardName": "LaunchScreen",
"NSAppTransportSecurity": ["NSAllowsArbitraryLoads": true],
// "LSApplicationQueriesSchemes" : [
// "kakaokompassauth",
// "kakaolink"
// ],
"UIAppFonts": [
"Pretendard-Black.otf",
"Pretendard-Bold.otf",
"Pretendard-ExtraBold.otf",
"Pretendard-ExtraLight.otf",
"Pretendard-Light.otf",
"Pretendard-Medium.otf",
"Pretendard-Regular.otf",
"Pretendard-SemiBold.otf",
"Pretendard-Thin.otf"
]
]
)
let mainAppTarget = [
Target.init(
name: Ticlemoa.projectName,
platform: .iOS,
product: .app,
productName: Ticlemoa.productName,
bundleId: "\(Ticlemoa.bundleId).\(Ticlemoa.projectName)",
deploymentTarget: Ticlemoa.deploymentTarget,
infoPlist: infoPlist,
sources: ["Targets/\(Ticlemoa.projectName)/Sources/**"],
resources: ["Targets/\(Ticlemoa.projectName)/Resources/**"],
dependencies: [
.target(name: Ticlemoa.userInterface.name),
.target(name: Ticlemoa.domain.name),
// .target(name: Ticlemoa.share.name)
]
),
Target.init(
name: "\(Ticlemoa.projectName)Tests",
platform: .iOS,
product: .unitTests,
bundleId: "\(Ticlemoa.bundleId).\(Ticlemoa.projectName)Tests",
deploymentTarget: Ticlemoa.deploymentTarget,
infoPlist: .default,
sources: ["Targets/\(Ticlemoa.projectName)/Tests/**"],
scripts: [],
dependencies: [
.target(name: Ticlemoa.projectName),
],
settings: nil,
coreDataModels: [],
environment: [:],
launchArguments: [],
additionalFiles: []
)
]
let project = Project.init(
name: Ticlemoa.projectName,
organizationName: Ticlemoa.organizationName,
targets: [
mainAppTarget,
userInterface,
domain,
api,
// share,
domainInterface
].flatMap { $0 }
)