-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathPackage.swift
87 lines (80 loc) · 3.09 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
// swift-tools-version:5.10
import Foundation
import PackageDescription
let package = Package(
name: "WordPressShared",
platforms: [.iOS(.v13), .macOS(.v12)],
products: [
.library(name: "WordPressShared", targets: ["WordPressShared"])
],
dependencies: [
.package(url: "https://github.com/buildkite/test-collector-swift", from: "0.3.0"),
.package(url: "https://github.com/AliSoftware/OHHTTPStubs", from: "9.1.0"),
// See https://github.com/erikdoe/ocmock/issues/500#issuecomment-1002700625
.package(url: "https://github.com/erikdoe/ocmock", revision: "afd2c6924e8a36cb872bc475248b978f743c6050"),
.package(url: "https://github.com/Quick/Quick", from: "6.0.0"),
.package(url: "https://github.com/realm/SwiftLint", exact: loadSwiftLintVersion())
],
targets: [
.target(
name: "WordPressSharedObjC",
resources: [.process("Resources")]
),
.target(
name: "WordPressShared",
dependencies: [
.target(name: "WordPressSharedObjC"),
],
resources: [.process("Resources")],
plugins: [
.plugin(name: "SwiftLintPlugin", package: "SwiftLint")
]
),
.testTarget(
name: "WordPressSharedTests",
dependencies: [
.target(name: "WordPressShared"),
.product(name: "OCMock", package: "ocmock"),
.product(name: "BuildkiteTestCollector", package: "test-collector-swift"),
"Quick",
"OHHTTPStubs",
],
plugins: [
.plugin(name: "SwiftLintPlugin", package: "SwiftLint")
]
),
.testTarget(
name: "WordPressSharedObjCTests",
dependencies: [
.target(name: "WordPressShared"),
.product(name: "OCMock", package: "ocmock"),
.product(name: "BuildkiteTestCollector", package: "test-collector-swift"),
"Quick",
"OHHTTPStubs",
],
resources: [.process("Resources")],
plugins: [
.plugin(name: "SwiftLintPlugin", package: "SwiftLint")
]
),
]
)
func loadSwiftLintVersion() -> Version {
let swiftLintConfigURL = URL(fileURLWithPath: #file)
.deletingLastPathComponent()
.appendingPathComponent(".swiftlint.yml")
guard let yamlString = try? String(contentsOf: swiftLintConfigURL) else {
fatalError("Failed to read SwiftLint config file at \(swiftLintConfigURL).")
}
guard let versionLine = yamlString.components(separatedBy: .newlines)
.first(where: { $0.contains("swiftlint_version") }) else {
fatalError("SwiftLint version not found in YAML file.")
}
// Assumes the format `swiftlint_version: <version>`
guard let version = Version(versionLine.components(separatedBy: ":")
.last?
.trimmingCharacters(in: .whitespaces) ?? "") else {
fatalError("Failed to extract SwiftLint version.")
}
return version
}