forked from ChartsOrg/Charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
86 lines (68 loc) · 1.75 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
def type
:project # set `:project` for xcodeproj and `:workspace` for xcworkspace
end
def project_name
"Charts/Charts.xcodeproj"
end
def configuration
"Debug"
end
def test_targets
[
:ios,
# :tvos #no tvOS fbsnapshot
]
end
def schemes
{
ios: 'Charts-iOS',
tvos: 'Charts-TV'
}
end
def sdks
{
ios: 'iphonesimulator',
osx: 'macosx',
tvos: 'appletvsimulator'
}
end
def devices
{
ios: "name='iPhone 6s'",
osx: "arch='x86_64'",
tvos: "name='Apple TV 1080p'"
}
end
def xcodebuild(type, name, scheme, configuration, sdk, destination, tasks, xcprety_args: '')
# set either workspace or project flag for xcodebuild
case type
when :project
project_type = "-project"
when :workspace
project_type = "-workspace"
else
abort "Invalid project type, use `:project` for xcodeproj and `:workspace` for xcworkspace."
end
sh "set -o pipefail && xcodebuild #{project_type} '#{name}' -scheme '#{scheme}' -configuration '#{configuration}' -sdk #{sdk} -destination #{destination} #{tasks} | xcpretty -c #{xcprety_args}"
end
def execute(tasks, platform, xcprety_args)
# platform specific settings
sdk = sdks[platform]
scheme = schemes[platform]
destination = devices[platform]
# check if xcodebuild needs to be run on multiple devices
if destination.respond_to?('map')
destination.map do |destination|
xcodebuild type, project_name, scheme, configuration, sdk, destination, tasks, xcprety_args
end
else
xcodebuild type, project_name, scheme, configuration, sdk, destination, tasks, xcprety_args
end
end
desc 'Build, then run tests.'
task :test do
test_targets.map do |platform|
execute 'build test', platform, xcprety_args: '--test'
end
sh "killall Simulator"
end