Class: Fastlane::Actions::CarthageAction

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

Constant Summary

Constants inherited from Fastlane::Action

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

Class Method Summary collapse

Methods inherited from Fastlane::Action

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

Class Method Details

.authorsObject



210
211
212
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 210

def self.authors
  ["bassrock", "petester42", "jschmid", "JaviSoto", "uny", "phatblat", "bfcrampton", "antondomashnev", "gbrhaz"]
end

.available_commandsObject



56
57
58
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 56

def self.available_commands
  %w(build bootstrap update archive)
end

.available_optionsObject



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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 64

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :command,
                                 env_name: "FL_CARTHAGE_COMMAND",
                                 description: "Carthage command (one of: #{available_commands.join(', ')})",
                                 default_value: 'bootstrap',
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass a valid command. Use one of the following: #{available_commands.join(', ')}") unless available_commands.include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :dependencies,
                                 description: "Carthage dependencies to update, build or bootstrap",
                                 default_value: [],
                                 is_string: false,
                                 type: Array),
    FastlaneCore::ConfigItem.new(key: :use_ssh,
                                 env_name: "FL_CARTHAGE_USE_SSH",
                                 description: "Use SSH for downloading GitHub repositories",
                                 is_string: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :use_submodules,
                                 env_name: "FL_CARTHAGE_USE_SUBMODULES",
                                 description: "Add dependencies as Git submodules",
                                 is_string: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :use_binaries,
                                 env_name: "FL_CARTHAGE_USE_BINARIES",
                                 description: "Check out dependency repositories even when prebuilt frameworks exist",
                                 is_string: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :no_build,
                                 env_name: "FL_CARTHAGE_NO_BUILD",
                                 description: "When bootstrapping Carthage do not build",
                                 is_string: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :no_skip_current,
                                 env_name: "FL_CARTHAGE_NO_SKIP_CURRENT",
                                 description: "Don't skip building the Carthage project (in addition to its dependencies)",
                                 is_string: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :derived_data,
                                 env_name: "FL_CARTHAGE_DERIVED_DATA",
                                 description: "Use derived data folder at path",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :verbose,
                                 env_name: "FL_CARTHAGE_VERBOSE",
                                 description: "Print xcodebuild output inline",
                                 is_string: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :platform,
                                 env_name: "FL_CARTHAGE_PLATFORM",
                                 description: "Define which platform to build for",
                                 optional: true,
                                 verify_block: proc do |value|
                                   value.split(',').each do |platform|
                                     UI.user_error!("Please pass a valid platform. Use one of the following: #{available_platforms.join(', ')}") unless available_platforms.map(&:downcase).include?(platform.downcase)
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :cache_builds,
                                 env_name: "FL_CARTHAGE_CACHE_BUILDS",
                                 description: "By default Carthage will rebuild a dependency regardless of whether it's the same resolved version as before. Passing the --cache-builds will cause carthage to avoid rebuilding a dependency if it can",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :frameworks,
                                 description: "Framework name or names to archive, could be applied only along with the archive command",
                                 default_value: [],
                                 is_string: false,
                                 type: Array),
    FastlaneCore::ConfigItem.new(key: :output,
                                 description: "Output name for the archive, could be applied only along with the archive command. Use following format *.framework.zip",
                                 is_string: true,
                                 optional: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass a valid string for output. Use following format *.framework.zip") unless value.end_with?("framework.zip")
                                 end),
    FastlaneCore::ConfigItem.new(key: :configuration,
                                 env_name: "FL_CARTHAGE_CONFIGURATION",
                                 description: "Define which build configuration to use when building",
                                 optional: true,
                                 verify_block: proc do |value|
                                   if value.chomp(' ').empty?
                                     UI.user_error!("Please pass a valid build configuration. You can review the list of configurations for this project using the command: xcodebuild -list")
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :toolchain,
                                 env_name: "FL_CARTHAGE_TOOLCHAIN",
                                 description: "Define which xcodebuild toolchain to use when building",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :project_directory,
                                 env_name: "FL_CARTHAGE_PROJECT_DIRECTORY",
                                 description: "Define the directory containing the Carthage project",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :new_resolver,
                                 env_name: "FL_CARTHAGE_NEW_RESOLVER",
                                 description: "Use new resolver when resolving dependency graph",
                                 is_string: false,
                                 optional: true,
                                 type: Boolean),
    FastlaneCore::ConfigItem.new(key: :log_path,
                                 env_name: "FL_CARTHAGE_LOG_PATH",
                                 description: "Path to the xcode build output",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :executable,
                                 env_name: "FL_CARTHAGE_EXECUTABLE",
                                 description: "Path to the `carthage` executable on your machine",
                                 default_value: 'carthage')
  ]
end

.available_platformsObject



60
61
62
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 60

def self.available_platforms
  %w(all iOS Mac tvOS watchOS)
end

.categoryObject



202
203
204
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 202

def self.category
  :building
end

.descriptionObject



52
53
54
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 52

def self.description
  "Runs `carthage` for your project"
end

.example_codeObject



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 178

def self.example_code
  [
    'carthage',
    'carthage(
      frameworks: ["MyFramework1", "MyFramework2"],   # Specify which frameworks to archive (only for the archive command)
      output: "MyFrameworkBundle.framework.zip",      # Specify the output archive name (only for the archive command)
      command: "bootstrap",                           # One of: build, bootstrap, update, archive. (default: bootstrap)
      dependencies: ["Alamofire", "Notice"],          # Specify which dependencies to update or build (only for update, build and bootstrap commands)
      use_ssh: false,                                 # Use SSH for downloading GitHub repositories.
      use_submodules: false,                          # Add dependencies as Git submodules.
      use_binaries: true,                             # Check out dependency repositories even when prebuilt frameworks exist
      no_build: false,                                # When bootstrapping Carthage do not build
      no_skip_current: false,                         # Don\'t skip building the current project (only for frameworks)
      verbose: false,                                 # Print xcodebuild output inline
      platform: "all",                                # Define which platform to build for (one of ‘all’, ‘Mac’, ‘iOS’, ‘watchOS’, ‘tvOS‘, or comma-separated values of the formers except for ‘all’)
      configuration: "Release",                       # Build configuration to use when building
      cache_builds: true,                             # By default Carthage will rebuild a dependency regardless of whether its the same resolved version as before.
      toolchain: "com.apple.dt.toolchain.Swift_2_3",  # Specify the xcodebuild toolchain
      new_resolver: false,                            # Use the new resolver to resolve depdendency graph
      log_path: "carthage.log"                        # Path to the xcode build output
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



206
207
208
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 206

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

.run(params) ⇒ Object

rubocop:disable Metrics/PerceivedComplexity



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

def self.run(params)
  validate(params)

  cmd = [params[:executable]]
  command_name = params[:command]
  cmd << command_name

  if command_name == "archive" && params[:frameworks].count > 0
    cmd.concat(params[:frameworks])
  elsif ["update", "build", "bootstrap"].include?(command_name) && params[:dependencies].count > 0
    cmd.concat(params[:dependencies])
  end

  cmd << "--output #{params[:output]}" if params[:output]
  cmd << "--use-ssh" if params[:use_ssh]
  cmd << "--use-submodules" if params[:use_submodules]
  cmd << "--no-use-binaries" if params[:use_binaries] == false
  cmd << "--no-build" if params[:no_build] == true
  cmd << "--no-skip-current" if params[:no_skip_current] == true
  cmd << "--verbose" if params[:verbose] == true
  cmd << "--platform #{params[:platform]}" if params[:platform]
  cmd << "--configuration #{params[:configuration]}" if params[:configuration]
  cmd << "--derived-data #{params[:derived_data].shellescape}" if params[:derived_data]
  cmd << "--toolchain #{params[:toolchain]}" if params[:toolchain]
  cmd << "--project-directory #{params[:project_directory]}" if params[:project_directory]
  cmd << "--cache-builds" if params[:cache_builds]
  cmd << "--new-resolver" if params[:new_resolver]
  cmd << "--log-path #{params[:log_path]}" if params[:log_path]

  Actions.sh(cmd.join(' '))
end

.validate(params) ⇒ Object

rubocop:enable Metrics/PerceivedComplexity



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'fastlane/lib/fastlane/actions/carthage.rb', line 38

def self.validate(params)
  command_name = params[:command]
  if command_name != "archive" && params[:frameworks].count > 0
    UI.user_error!("Frameworks option is available only for 'archive' command.")
  end
  if command_name != "archive" && params[:output]
    UI.user_error!("Output option is available only for 'archive' command.")
  end

  if params[:log_path] && !%w(build bootstrap update).include?(command_name)
    UI.user_error!("Log path option is available only for 'build', 'bootstrap', and 'update' command.")
  end
end