Class: Fastlane::Helper::CreateXcframeworkHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ CreateXcframeworkHelper

Returns a new instance of CreateXcframeworkHelper.



4
5
6
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 4

def initialize(params)
  @params = params
end

Instance Method Details

#frameworkObject



16
17
18
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 16

def framework
  "#{product_name}.framework"
end

#library_identifier(framework_index) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 63

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

#output_directoryObject



59
60
61
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 59

def output_directory
  @params[:xcframework_output_directory] ? @params[:xcframework_output_directory] : ''
end

#product_nameObject



8
9
10
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 8

def product_name
  @params[:product_name] ||= @params[:scheme]
end

#xcarchive_BCSymbolMaps_path(framework_index) ⇒ Object



47
48
49
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 47

def xcarchive_BCSymbolMaps_path(framework_index)
  File.expand_path("#{xcarchive_path_for_destination(framework_index)}/BCSymbolMaps")
end

#xcarchive_dSYMs_path(framework_index) ⇒ Object



39
40
41
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 39

def xcarchive_dSYMs_path(framework_index)
  File.expand_path("#{xcarchive_path_for_destination(framework_index)}/dSYMS")
end

#xcarchive_framework_path(framework_index) ⇒ Object



28
29
30
31
32
33
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 28

def xcarchive_framework_path(framework_index)
  framework_path = "#{xcarchive_path_for_destination(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

#xcarchive_frameworks_pathObject



35
36
37
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 35

def xcarchive_frameworks_path
  @params[:destinations].each_with_index.map { |_, i| xcarchive_framework_path(i) }
end

#xcarchive_pathObject



20
21
22
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 20

def xcarchive_path
  "#{output_directory}/archives"
end

#xcarchive_path_for_destination(framework_index) ⇒ Object



24
25
26
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 24

def xcarchive_path_for_destination(framework_index)
  "#{xcarchive_path}/#{framework_index}_#{product_name}.xcarchive"
end

#xcframeworkObject



12
13
14
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 12

def xcframework
  "#{product_name}.xcframework"
end

#xcframework_BCSymbolMaps_pathObject



51
52
53
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 51

def xcframework_BCSymbolMaps_path
  File.expand_path("#{output_directory}/#{product_name}.BCSymbolMaps")
end

#xcframework_dSYMs_pathObject



43
44
45
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 43

def xcframework_dSYMs_path
  File.expand_path("#{output_directory}/#{product_name}.dSYMs")
end

#xcframework_pathObject



55
56
57
# File 'lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb', line 55

def xcframework_path
  File.expand_path("#{output_directory}/#{xcframework}")
end