Class: Fastlane::Actions::CreateXcframeworkAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/create_xcframework.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



109
110
111
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 109

def self.authors
  ["jgongo"]
end

.available_optionsObject



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
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 48

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :frameworks,
                                 env_name: "FL_CREATE_XCFRAMEWORK_FRAMEWORKS",
                                 description: "Frameworks to add to the target xcframework",
                                 type: Array,
                                 optional: true,
                                 conflicting_options: [:libraries],
                                 verify_block: proc do |value|
                                   value.each do |framework|
                                     UI.user_error!("#{framework} doesn't end with '.framework'. Is this really a framework?") unless framework.end_with?('.framework')
                                     UI.user_error!("Couldn't find framework at #{framework}") unless File.exist?(framework)
                                     UI.user_error!("#{framework} doesn't seem to be a framework") unless File.directory?(framework)
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :libraries,
                                 env_name: "FL_CREATE_XCFRAMEWORK_LIBRARIES",
                                 description: "Libraries to add to the target xcframework, with their corresponding headers",
                                 type: Hash,
                                 optional: true,
                                 conflicting_options: [:frameworks],
                                 verify_block: proc do |value|
                                   value.each do |library, headers|
                                     UI.user_error!("Couldn't find library at #{library}") unless File.exist?(library)
                                     UI.user_error!("#{headers} doesn't exist or is not a directory") unless headers.empty? || File.directory?(headers)
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :output,
                                 env_name: "FL_CREATE_XCFRAMEWORK_OUTPUT",
                                 description: "The path to write the xcframework to",
                                 type: String,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :allow_internal_distribution,
                                 env_name: "FL_CREATE_XCFRAMEWORK_ALLOW_INTERNAL_DISTRIBUTION",
                                 description: "Specifies that the created xcframework contains information not suitable for public distribution",
                                 type: Boolean,
                                 optional: true,
                                 default_value: false)
  ]
end

.categoryObject



105
106
107
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 105

def self.category
  :building
end

.descriptionObject



26
27
28
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 26

def self.description
  "Package multiple build configs of a library/framework into a single xcframework"
end

.detailsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 30

def self.details
  <<~DETAILS
    Utility for packaging multiple build configurations of a given library
    or framework into a single xcframework.

    If you want to package several frameworks just provide an array containing
    the list of frameworks to be packaged using the :frameworks parameter.

    If you want to package several libraries with their corresponding headers
    provide a hash containing the library as the key and the directory containing
    its headers as the value (or an empty string if there are no headers associated
    with the provided library).

    Finally specify the location of the xcframework to be generated using the :output
    parameter.
  DETAILS
end

.example_codeObject



98
99
100
101
102
103
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 98

def self.example_code
  [
    "create_xcframework(frameworks: ['FrameworkA.framework', 'FrameworkB.framework'], output: 'UniversalFramework.xcframework')",
    "create_xcframework(libraries: { 'LibraryA.so' => '', 'LibraryB.so' => 'LibraryBHeaders'}, output: 'UniversalFramework.xcframework')"
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



113
114
115
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 113

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.outputObject



89
90
91
92
93
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 89

def self.output
  [
    ['XCFRAMEWORK_PATH', 'Location of the generated xcframework']
  ]
end

.return_valueObject



95
96
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 95

def self.return_value
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'fastlane/lib/fastlane/actions/create_xcframework.rb', line 8

def self.run(params)
  UI.user_error!("Please provide either :frameworks or :libraries to be packaged into the xcframework") unless params[:frameworks] || params[:libraries]

  create_command = ['xcodebuild', '-create-xcframework']
  create_command << params[:frameworks].map { |framework| ['-framework', "\"#{framework}\""] }.flatten if params[:frameworks]
  create_command << params[:libraries].map { |library, headers| ['-library', "\"#{library}\""] + (headers.empty? ? [] : ['-headers', "\"#{headers}\""]) } if params[:libraries]
  create_command << ['-output', "\"#{params[:output]}\""]
  create_command << ['-allow-internal-distribution'] if params[:allow_internal_distribution]

  Actions.lane_context[SharedValues::XCFRAMEWORK_PATH] = params[:output]

  sh(create_command)
end