forked from fabianmuecke/mockingbird
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Package.swift
128 lines (123 loc) · 3.95 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
// swift-tools-version:5.2
import class Foundation.ProcessInfo
import PackageDescription
/// The manifest is split into several sub-packages based on build type. It's a slight hack, but
/// does offer a few advantages until SPM evolves, such as no package dependencies when consuming
/// just the framework product, target-specific platform requirements, and SwiftUI compatibility.
let package: Package =
// MARK: Framework
.init(
name: "Mockingbird",
platforms: [
.macOS(.v10_15),
.iOS(.v9),
.tvOS(.v9),
.watchOS("7.4"),
],
products: [
.library(name: "Mockingbird", targets: ["Mockingbird", "MockingbirdObjC"]),
],
targets: [
.target(
name: "Mockingbird",
dependencies: ["MockingbirdBridge", "MockingbirdCommon"],
path: "Sources",
exclude: ["MockingbirdFramework/Objective-C"],
sources: ["MockingbirdFramework"],
swiftSettings: [.define("MKB_SWIFTPM")],
linkerSettings: [.linkedFramework("XCTest")]
),
.target(
name: "MockingbirdObjC",
dependencies: ["Mockingbird", "MockingbirdBridge"],
path: "Sources/MockingbirdFramework/Objective-C",
exclude: ["Bridge"],
cSettings: [.headerSearchPath("./"), .define("MKB_SWIFTPM")]
),
.target(
name: "MockingbirdBridge",
path: "Sources/MockingbirdFramework/Objective-C/Bridge",
cSettings: [.headerSearchPath("include"), .define("MKB_SWIFTPM")]
),
.target(name: "MockingbirdCommon"),
]
)
if ProcessInfo.processInfo.environment["MKB_BUILD_EXECUTABLES"] == "1" {
// MARK: Executables
package.products += [
.executable(name: "mockingbird", targets: ["MockingbirdCli"]),
.executable(name: "automation", targets: ["MockingbirdAutomationCli"]),
]
package.dependencies += [
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.0.2")),
.package(url: "https://github.com/kylef/PathKit.git", .exact("1.0.1")),
.package(
name: "SwiftSyntax",
url: "https://github.com/apple/swift-syntax.git",
.exact("0.50600.1")
),
.package(url: "https://github.com/jpsim/SourceKitten.git", .exact("0.32.0")),
.package(url: "https://github.com/tuist/XcodeProj.git", .exact("8.7.1")),
.package(url: "https://github.com/weichsel/ZIPFoundation.git", .exact("0.9.14")),
]
package.targets += [
.target(
name: "MockingbirdCli",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"MockingbirdCommon",
"MockingbirdGenerator",
"XcodeProj",
"ZIPFoundation",
],
linkerSettings: [
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", "@executable_path"]),
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", "@executable_path/Libraries"]),
]
),
.target(
name: "MockingbirdGenerator",
dependencies: [
.product(name: "SourceKittenFramework", package: "SourceKitten"),
"MockingbirdCommon",
"SwiftSyntax",
.product(name: "SwiftSyntaxParser", package: "SwiftSyntax"),
"XcodeProj",
]
),
.target(
name: "MockingbirdAutomationCli",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"MockingbirdAutomation",
"MockingbirdCommon",
"PathKit",
]
),
.target(
name: "MockingbirdAutomation",
dependencies: [
"MockingbirdCommon",
"PathKit",
]
),
.testTarget(
name: "MockingbirdAutomationTests",
dependencies: ["MockingbirdAutomation"]
),
]
}
extension Package {
func merge(with other: Package) {
if let platforms = self.platforms {
if let other = other.platforms {
self.platforms = platforms + other
}
} else {
self.platforms = other.platforms
}
self.dependencies += other.dependencies
self.products += other.products
self.targets += other.targets
}
}