forked from AliSoftware/Reusable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
95 lines (78 loc) · 2.6 KB
/
Rakefile
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
#!/usr/bin/rake
## UTILS ##
def run(command, xcpretty: true)
if xcpretty && system('xcpretty --version >/dev/null')
sh "set -o pipefail && #{command} | xcpretty -c"
else
sh command
end
end
def xcodebuild(scheme: '', sdk: '', destination: '', action: 'build')
run %Q(xcodebuild -workspace Example/ReusableDemo.xcworkspace -scheme "#{scheme}" -sdk #{sdk} -destination="#{destination}" ONLY_ACTIVE_ARCH=NO #{action})
end
DESTINATIONS = {
:ios_sim => "OS=9.3,name=iPhone 6,platform=iOS Simulator",
:tvos_sim => "OS=10.1,name=Apple TV 1080p,platform=tvOS Simulator",
}
def install_pkg(pkg_url)
tmppath = '/tmp/' + File.basename(pkg_url)
sh("curl -Lo #{tmppath} #{pkg_url}")
sh("sudo installer -pkg #{tmppath} -target /")
end
## TASKS ##
namespace :carthage do
desc "Install Carthage from pkg"
task :install do
next if system('which carthage >/dev/null')
install_pkg('https://github.com/Carthage/Carthage/releases/download/0.33.0/Carthage.pkg')
end
desc "Builds the Reusable framework using Carthage"
task :build do
run "carthage build --no-skip-current --verbose"
end
end
namespace :demo do
desc "Builds the ReusableDemo app for iOS using xcodebuild."
task :ios do |t, args|
xcodebuild(scheme: 'ReusableDemo iOS', sdk: 'iphonesimulator', destination: DESTINATIONS[:ios_sim])
end
desc "Builds the ReusableDemo app for tvOS using xcodebuild."
task :tvos do |t, args|
xcodebuild(scheme: 'ReusableDemo tvOS', sdk: 'appletvsimulator', destination: DESTINATIONS[:tvos_sim])
end
end
namespace :fmk do
desc "Builds the Reusable framework for iOS using xcodebuild."
task :ios do |t, args|
xcodebuild(scheme: 'Reusable-iOS', sdk: 'iphonesimulator', destination: DESTINATIONS[:ios_sim])
end
desc "Builds the Reusable framework for tvOS using xcodebuild."
task :tvos do |t, args|
xcodebuild(scheme: 'Reusable-tvOS', sdk: 'appletvsimulator', destination: DESTINATIONS[:tvos_sim])
end
end
namespace :pod do
desc "Lints the Reusable.podspec"
task :lint do |t|
run("pod lib lint --allow-warnings --quick", xcpretty: false)
end
end
namespace :spm do
desc 'Build using SPM'
task :build do |task|
puts '*** Compile using SPM ***'
sh 'xcrun swift build'
end
end
namespace :swiftlint do
desc "Install SwiftLint from pkg"
task :install do
next if system('which swiftlint >/dev/null')
install_pkg('https://github.com/realm/SwiftLint/releases/download/0.26.0/SwiftLint.pkg')
end
desc "Run SwiftLint on the source code"
task :run do
run('swiftlint lint --strict', xcpretty: false)
end
end
# TODO: "namespace :test" once we have Unit Tests