forked from 42Box/iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject.swift
124 lines (108 loc) · 4.07 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
import ProjectDescription
// MARK: - Project Factory
protocol ProjectFactory {
var projectName: String { get }
var dependencies: [TargetDependency] { get }
func generateTarget() -> [Target]
}
// 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": "iBox",
"CFBundleName": "iBox",
"CFBundleShortVersionString": "1.0.0",
"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": "iBox.Share",
"CFBundleShortVersionString": "1.0.0",
"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()
)