-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathPackage.swift
120 lines (105 loc) · 3.47 KB
/
Package.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
// swift-tools-version: 6.0
import Foundation
import PackageDescription
// You can enable/disable Datadog for debugging by overriding the boolean.
let isDatadogEnabled = hasEnvironmentVariable("ENABLE_DATADOG", "true")
let isCountlyEnabled = hasEnvironmentVariable("ENABLE_COUNTLY", "true")
let package = Package(
name: "WireAnalytics",
platforms: [.iOS("16.4"), .macOS(.v12)],
products: [
.library(name: "WireAnalytics", targets: ["WireAnalytics"]),
.library(name: "WireAnalyticsSupport", targets: ["WireAnalyticsSupport"]),
.library(name: "WireCountly", targets: ["WireCountly"]),
.library(name: "WireDatadog", targets: ["WireDatadog"])
],
dependencies: [
.package(url: "https://github.com/Countly/countly-sdk-ios.git", exact: "24.4.2"),
.package(url: "https://github.com/DataDog/dd-sdk-ios.git", exact: "2.18.0"),
.package(path: "../WireLogging"),
.package(path: "../WirePlugins")
],
targets: [
.target(
name: "WireAnalytics",
dependencies: ["WireLogging"]
),
.target(
name: "WireAnalyticsSupport",
dependencies: ["WireAnalytics"],
plugins: [.plugin(name: "SourceryPlugin", package: "WirePlugins")]
),
.testTarget(
name: "WireAnalyticsTests",
dependencies: ["WireAnalytics", "WireAnalyticsSupport"]
),
.target(
name: "WireCountly",
dependencies: countlyDependencies() + ["WireAnalytics"],
sources: countlyFiles()
),
.target(
name: "WireDatadog",
dependencies: datadogDependencies() + ["WireLogging"],
sources: datadogFiles()
),
// This target prevents warnings about `countly-sdk-ios` or `dd-sdk-ios` not being used.
.target(
name: "WarningPrevention",
dependencies: [
.product(name: "Countly", package: "countly-sdk-ios"),
.product(name: "DatadogCore", package: "dd-sdk-ios")
]
)
]
)
// MARK: - Countly
func countlyDependencies() -> [Target.Dependency] {
guard isCountlyEnabled else {
return []
}
return [
.product(name: "Countly", package: "countly-sdk-ios")
]
}
func countlyFiles() -> [String] {
if isCountlyEnabled {
["CountlyWrapper.swift"]
} else {
["CountlyDummy.swift"]
}
}
// MARK: - Datadog
func datadogDependencies() -> [Target.Dependency] {
guard isDatadogEnabled else {
return []
}
return [
.product(name: "DatadogCore", package: "dd-sdk-ios"),
.product(name: "DatadogCrashReporting", package: "dd-sdk-ios"),
.product(name: "DatadogLogs", package: "dd-sdk-ios"),
.product(name: "DatadogRUM", package: "dd-sdk-ios"),
.product(name: "DatadogTrace", package: "dd-sdk-ios")
]
}
func datadogFiles() -> [String] {
if isDatadogEnabled {
["WireDatadog.swift"]
} else {
["WireFakeDatadog.swift"]
}
}
// MARK: -
func hasEnvironmentVariable(_ name: String, _ value: String? = nil) -> Bool {
if let value {
ProcessInfo.processInfo.environment[name] == value
} else {
ProcessInfo.processInfo.environment[name] != nil
}
}
for target in package.targets {
target.swiftSettings = (target.swiftSettings ?? []) + [
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("ExistentialAny")
]
}