-
Notifications
You must be signed in to change notification settings - Fork 2
/
Project.swift
132 lines (114 loc) · 4.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
import ProjectDescription
// MARK: - Project Factory
protocol ProjectFactory {
var projectName: String { get }
var dependencies: [TargetDependency] { get }
func generateTarget() -> [Target]
}
// MARK: - Plist.Value Extension
extension Plist.Value {
static var displayName: Plist.Value = "42Box"
static var displayShareExtensionName: Plist.Value = "42Box.Share"
static var appVersion: Plist.Value = "1.1.1"
}
// MARK: - iBox Factory
class iBoxFactory: ProjectFactory {
let projectName: String = "iBox"
let bundleId: String = "com.box42.iBox"
let iosVersion: String = "15.0"
let dependencies: [TargetDependency] = [
.external(name: "SnapKit"),
.external(name: "SwiftSoup"),
.external(name: "SkeletonView"),
.target(name: "iBoxShareExtension")
]
let iBoxShareExtensionDependencies: [TargetDependency] = [
.external(name: "SnapKit")
]
private let appInfoPlist: [String: Plist.Value] = [
"ITSAppUsesNonExemptEncryption": false,
"CFBundleDisplayName": Plist.Value.displayName,
"CFBundleName": "iBox",
"CFBundleShortVersionString": Plist.Value.appVersion,
"CFBundleVersion": "1",
"UILaunchStoryboardName": "LaunchScreen",
"UIApplicationSceneManifest": [
"UIApplicationSupportsMultipleScenes": false,
"UISceneConfigurations": [
"UIWindowSceneSessionRoleApplication": [
[
"UISceneConfigurationName": "Default Configuration",
"UISceneDelegateClassName": "$(PRODUCT_MODULE_NAME).SceneDelegate"
],
]
]
],
"CFBundleURLTypes": [
[
"CFBundleURLName": "com.url.iBox",
"CFBundleURLSchemes": ["iBox"],
"CFBundleTypeRole": "Editor"
]
],
"NSAppTransportSecurity": [
"NSAllowsArbitraryLoadsInWebContent": true
]
]
private let shareExtensionInfoPlist: [String: Plist.Value] = [
"CFBundleDisplayName": Plist.Value.displayShareExtensionName,
"CFBundleShortVersionString": Plist.Value.appVersion,
"CFBundleVersion": "1",
"NSExtension": [
"NSExtensionAttributes": [
"NSExtensionActivationRule": [
"NSExtensionActivationSupportsWebPageWithMaxCount": 1,
"NSExtensionActivationSupportsWebURLWithMaxCount": 1,
"SUBQUERY": [
"extensionItems": [
"SUBQUERY": [
"attachments": [
"ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO 'public.data'": "TRUE"
],
"@count": 1
]
],
"@count": 1
]
]
],
"NSExtensionPointIdentifier": "com.apple.share-services",
"NSExtensionPrincipalClass": "$(PRODUCT_MODULE_NAME).CustomShareViewController"
]
]
func generateTarget() -> [ProjectDescription.Target] {
let appTarget = Target(
name: projectName,
destinations: .iOS,
product: .app,
bundleId: bundleId,
deploymentTargets: .iOS(iosVersion),
infoPlist: .extendingDefault(with: appInfoPlist),
sources: ["\(projectName)/Sources/**"],
resources: "\(projectName)/Resources/**",
dependencies: dependencies
)
let shareExtensionTarget = Target(
name: "\(projectName)ShareExtension",
destinations: .iOS,
product: .appExtension,
bundleId: "\(bundleId).ShareExtension",
deploymentTargets: .iOS(iosVersion),
infoPlist: .extendingDefault(with: shareExtensionInfoPlist),
sources: ["ShareExtension/Sources/**"],
resources: ["ShareExtension/Resources/**"],
dependencies: iBoxShareExtensionDependencies
)
return [appTarget, shareExtensionTarget]
}
}
// MARK: - Project
let factory = iBoxFactory()
let project: Project = .init(
name: factory.projectName,
targets: factory.generateTarget()
)