-
Notifications
You must be signed in to change notification settings - Fork 12
/
create_xcframework_helper.rb
78 lines (63 loc) · 2.43 KB
/
create_xcframework_helper.rb
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
module Fastlane
module Helper
class CreateXcframeworkHelper
def initialize(params)
@params = params
end
def product_name
@params[:product_name] ||= @params[:scheme]
end
def xcframework
"#{product_name}.xcframework"
end
def framework
"#{product_name}.framework"
end
def xcarchive_path(framework_index)
"#{framework_index}_#{product_name}.xcarchive"
end
def xcarchive_framework_path(framework_index)
framework_path = "#{xcarchive_path(framework_index)}/Products/Library/Frameworks/#{framework}"
return framework_path if File.exist?(framework_path)
FastlaneCore::UI.user_error!("▸ PRODUCT_NAME was misdefined: `#{product_name}`. Please, provide :product_name option")
end
def xcarchive_frameworks_path
@params[:destinations].each_with_index.map { |_, i| xcarchive_framework_path(i) }
end
def xcarchive_dSYMs_path(framework_index)
File.expand_path("#{xcarchive_path(framework_index)}/dSYMS")
end
def xcframework_dSYMs_path
File.expand_path("#{output_directory}/#{product_name}.dSYMs")
end
def xcarchive_BCSymbolMaps_path(framework_index)
File.expand_path("#{xcarchive_path(framework_index)}/BCSymbolMaps")
end
def xcframework_BCSymbolMaps_path
File.expand_path("#{output_directory}/#{product_name}.BCSymbolMaps")
end
def xcframework_path
File.expand_path("#{output_directory}/#{xcframework}")
end
def output_directory
@params[:xcframework_output_directory] ? @params[:xcframework_output_directory] : ''
end
def library_identifier(framework_index)
framework_path = xcarchive_framework_path(framework_index)
framework_basename = framework_path.split('/').last
framework_root = framework_basename.split('.').first
library_identifiers = Dir.chdir(xcframework_path) do
Dir.glob('*').select { |f| File.directory?(f) }
end
library_identifier = library_identifiers.detect do |id|
FileUtils.compare_file(
"#{framework_path}/#{framework_root}",
"#{xcframework_path}/#{id}/#{framework_basename}/#{framework_root}"
)
end
UI.user_error!("Error: #{xcframework_path} doesn't contain #{framework_path}") if library_identifier.nil?
library_identifier
end
end
end
end