-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSakefile.swift
92 lines (79 loc) · 3.36 KB
/
Sakefile.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
// https://github.com/xcodeswift/sake
import Foundation
import SakefileDescription
let project = "Result"
enum Platform: String {
case macOS
case iOS
case watchOS
case tvOS
}
var platform: Platform = .macOS
enum PlatformDestination: String {
case macOS_Simulator = "\"platform=OS X\""
case iOS_Simulator = "\"platform=iOS Simulator,name=iPhone 8\""
case watchOS_Simulator = "\"platform=watchOS Simulator,name=Apple Watch - 38mm\""
case tvOS_Simulator = "\"platform=tvOS Simulator,name=Apple TV\""
}
let destinations: [ Platform : PlatformDestination ] = [
.macOS: .macOS_Simulator,
.iOS: .iOS_Simulator,
.watchOS: .watchOS_Simulator,
.tvOS: .tvOS_Simulator
]
let sake = Sake(tasks: [
Task("xcodegen-clean", description: "Removed XCode Project Data") {
// Here is where you define your build task
try Utils.shell.runAndPrint(bash: "rm -rf HyperSpace.xcodreproj")
try Utils.shell.runAndPrint(bash: "rm -rf DerivedData")
},
Task("xcodegen", description: "Generate XCode Project Data") {
// Here is where you define your build task
try Utils.shell.runAndPrint(bash: "xcodegen")
},
Task("carthage-clean", description: "Cleans Project Carthage Dependencies") {
// Here is where you define your build task
try Utils.shell.runAndPrint(bash: "rm -rf Cartfile.resolved")
try Utils.shell.runAndPrint(bash: "rm -rf Carthage")
},
Task("carthage-build-platform-dependencies", description: "Builds project Carthage dependencies for platform") {
// Here is where you define your build task
try Utils.shell.runAndPrint(bash: "carthage bootstrap --platform \(platform)")
// try Utils.shell.runAndPrint(bash: carthageBuild)
},
Task("xcode-build-platform", description: "Build specific platform with XCode") {
// Here is where you define your build task
let action = "xcodebuild clean build -project \(project).xcodeproj -scheme \(project)-\(platform) -quiet"
try Utils.shell.runAndPrint(bash: action)
},
Task("xcode-test-platform", description: "Test specific platform with XCode. XCPretty output.") {
// Here is where you define your build task
guard let destination = destinations[platform] else { fatalError() }
print("destination = \(destination.rawValue)")
switch platform {
case .macOS:
let action = "set -o pipefail && xcodebuild test -project \(project).xcodeproj -scheme \(project)-\(platform) -destination \(destination.rawValue) | xcpretty"
try Utils.shell.runAndPrint(bash: action)
case .iOS,.tvOS:
let action = "set -o pipefail && xcodebuild test -project \(project).xcodeproj -scheme \(project)-\(platform) -destination \(destination.rawValue) -enableCodeCoverage YES | xcpretty"
try Utils.shell.runAndPrint(bash: action)
case .watchOS:
()
}
},
],
hooks: [
.beforeAll({
/* Before all the tasks */
do {
let platformString = try Utils.shell.run(bash: "echo $PLATFORM")
print("platform string = \(platformString)")
guard let _platform = Platform(rawValue: platformString) else { fatalError() }
print("_platform = \(_platform)")
platform = _platform
print("platform = \(platform)")
} catch {
}
})
]
)