forked from mapbox/mapbox-maps-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Package.swift
134 lines (115 loc) · 4.96 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let coreMaps = MapsDependency.coreMaps(version: "11.0.0-rc.2")
let common = MapsDependency.common(version: "24.0.0-rc.3")
let mapboxMapsPath: String? = nil
let package = Package(
name: "MapboxMaps",
defaultLocalization: "en",
platforms: [.iOS(.v12)],
products: [
.library(
name: "MapboxMaps",
targets: ["MapboxMaps"]),
],
dependencies: [
.package(url: "https://github.com/mapbox/turf-swift.git", exact: "2.7.0"),
] + coreMaps.packageDependencies + common.packageDependencies,
targets: [
.target(
name: "MapboxMaps",
dependencies: [
coreMaps.mapsTargetDependencies,
common.mapsTargetDependencies,
.product(name: "Turf", package: "turf-swift")
],
path: mapboxMapsPath,
exclude: [
"Info.plist",
],
resources: [
.copy("MapboxMaps.json"),
.copy("PrivacyInfo.xcprivacy"),
]
),
.testTarget(
name: "MapboxMapsTests",
dependencies: [
"MapboxMaps",
],
resources: [
.copy("MigrationGuide/Fixtures/polygon.geojson"),
.copy("Helpers/MapboxAccessToken"),
.copy("Resources/empty-style-chicago.json"),
.copy("Snapshot/testDoesNotShowAttribution().png"),
.copy("Snapshot/testDoesNotShowLogo().png"),
.copy("Snapshot/testDoesNotShowLogoAndAttribution().png"),
.copy("Snapshot/testShowsLogoAndAttribution().png"),
.copy("Snapshot/testSnapshotAttribution-100.png"),
.copy("Snapshot/testSnapshotAttribution-150.png"),
.copy("Snapshot/testSnapshotAttribution-200.png"),
.copy("Snapshot/testSnapshotAttribution-250.png"),
.copy("Snapshot/testSnapshotAttribution-300.png"),
.copy("Snapshot/testSnapshotAttribution-50.png"),
.copy("Snapshot/testSnapshotLogoVisibility.png"),
.copy("Snapshot/testSnapshotOverlay.png"),
.process("Resources/MapInitOptionsTests.xib"),
]
)
] + coreMaps.packageTargets + common.packageTargets
)
struct MapsDependency {
init(name: String, version: String, checksum: String? = nil, isSnapshot: Bool?, repositoryName: String, registryProjectName: String, registryFileName: String) {
self.name = name
self.version = version
self.checksum = checksum
self.isSnapshot = isSnapshot ?? version.contains("SNAPSHOT")
self.repositoryName = repositoryName
self.registryProjectName = registryProjectName
self.registryFileName = registryFileName
}
let name: String
let version: String
let checksum: String?
let isSnapshot: Bool
let repositoryName: String
let registryProjectName: String
let registryFileName: String
static func coreMaps(version: String, checksum: String? = nil, isSnapshot: Bool? = nil) -> MapsDependency {
return MapsDependency(name: "MapboxCoreMaps", version: version, checksum: checksum, isSnapshot: isSnapshot,
repositoryName: "mapbox-core-maps-ios",
registryProjectName: "mobile-maps-core",
registryFileName: "MapboxCoreMaps.xcframework-dynamic.zip")
}
static func common(version: String, checksum: String? = nil, isSnapshot: Bool? = nil) -> MapsDependency {
return MapsDependency(name: "MapboxCommon", version: version, checksum: checksum, isSnapshot: isSnapshot,
repositoryName: "mapbox-common-ios",
registryProjectName: "mapbox-common",
registryFileName: "MapboxCommon.zip")
}
var packageDependencies: [Package.Dependency] {
guard !isSnapshot else { return [] }
return [
.package(url: repositoryURL, exact: Version(stringLiteral: version))
]
}
var packageTargets: [Target] {
guard isSnapshot else { return [] }
return [
.binaryTarget(name: name, url: registryURL, checksum: checksum ?? "")
]
}
var mapsTargetDependencies: Target.Dependency {
if isSnapshot {
return .byName(name: name)
} else {
return .product(name: name, package: repositoryName)
}
}
var repositoryURL: String { return "https://github.com/mapbox/\(repositoryName).git" }
var registryReleaseFolder: String { isSnapshot ? "snapshots" : "releases" }
var registryURL: String {
return "https://api.mapbox.com/downloads/v2/\(registryProjectName)/\(registryReleaseFolder)/ios/packages/\(version)/\(registryFileName)"
}
}