-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
128 lines (110 loc) · 4.43 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
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
namespace :build do
desc 'Builds all packages and executables'
task all: ['package:all', 'example:all', 'xcframework']
desc 'Builds the Smile ID package for supported platforms'
namespace :package do
desc 'Builds the Smile ID package for iOS'
task all: ['iOS']
desc 'Builds the Smile ID package for iOS'
task :iOS do
xcodebuild('build -scheme "SmileID" -destination generic/platform=iOS')
end
end
desc 'Builds the Smile ID example app for supported platforms'
namespace :example do
desc 'Builds the Smile ID example apps for all supported platforms'
task all: ['iOS']
desc 'Builds the iOS Smile ID Example app'
task :iOS do
xcodebuild('build -scheme "SmileID-Example" -destination "platform=iOS Simulator,name=iPhone SE (3rd generation)"')
end
end
desc 'Builds an xcframework for all supported platforms'
task :xcframework do
sh 'rm -rf archives'
sh 'rm -rf SmileID.xcframework'
sh 'rm -rf release'
xcodebuild('archive -scheme "SmileID" -destination "generic/platform=iOS Simulator" -archivePath "archives/ios_simulators.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO')
xcodebuild('archive -scheme "SmileID" -destination "generic/platform=iOS" -archivePath "archives/ios_devices.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO')
xcarchive('-create-xcframework -framework archives/ios_devices.xcarchive/Products/Library/Frameworks/SmileID.framework -framework archives/ios_simulators.xcarchive/Products/Library/Frameworks/SmileID.framework -output SmileID.xcframework')
sh 'mkdir release'
sh 'zip -r SmileID.zip SmileID.xcframework/'
sh 'sha256sum SmileID.zip > SmileID.sha256'
sh 'mv SmileID.zip SmileID.sha256 release/'
end
end
namespace :test do
desc 'Tests the package , processed the test results and tests spm compatibility'
task all: ['package', 'process', 'spm','example']
desc 'Tests the Smile ID package for iOS'
task :package do
xcodebuild('test -scheme "SmileID_Tests" -destination "platform=iOS Simulator,name=iPhone SE (3rd generation)"')
end
desc 'Tests the example app unit tests'
task :example do
xcodebuild('test -scheme "SmileID-Example" -destination "platform=iOS Simulator,name=iPhone SE (3rd generation)"')
end
desc 'Processes .xcresult artifacts from the most recent test:package execution'
task :process do
sh 'mint run ChargePoint/[email protected] xcparse attachments Tests/Artifacts/SmileIDTests.xcresult Tests/Artifacts/TestAttachments'
end
desc 'Tests Swift Package Manager support'
task :spm do
xcodebuild('build -scheme "SmileID" -destination generic/platform=iOS',"SmileID.xcodeproj")
end
end
namespace :lint do
desc 'Lints swift files'
task :swift do
sh 'mint run realm/SwiftLint'
end
desc 'Lints the CocoaPods podspec'
task :podspec do
sh 'pod lib lint SmileID.podspec'
end
end
namespace :format do
desc 'Formats swift files'
task :swift do
sh 'mint run swiftformat . --swiftversion 5.8'
end
end
def xcodebuild(command, project = "Example/SmileID.xcworkspace")
# Determine the project flag based on the file extension
project_flag = if project.end_with?(".xcworkspace")
"-workspace"
elsif project.end_with?(".xcodeproj")
"-project"
else
raise ArgumentError, "Invalid project type. Must be .xcworkspace or .xcodeproj"
end
# Check if the mint tool is installed -- if so, pipe the xcodebuild output through xcbeautify
`which mint`
sh 'rm -rf ~/Library/Developer/Xcode/DerivedData/* && echo "Successfully flushed DerivedData"'
if $?.success?
sh "set -o pipefail && xcodebuild #{command} #{project_flag} #{project} | mint run thii/[email protected]"
else
sh "xcodebuild #{command} #{project_flag} #{project}"
end
end
namespace :provision do
desc 'Provision the app for building'
task :ios do
Dir.chdir('Example') do
sh 'bundle install'
sh 'arkana -c .arkana.yml'
sh 'pod install'
sh 'bundle exec fastlane run_match'
end
end
end
def xcarchive(command)
# Check if the mint tool is installed -- if so, pipe the xcodebuild output through xcbeautify
`which mint`
sh 'rm -rf ~/Library/Developer/Xcode/DerivedData/* && echo "Successfully flushed DerivedData"'
if $?.success?
sh "set -o pipefail && xcodebuild #{command} | mint run thii/[email protected]"
else
sh "xcodebuild #{command}"
end
end