Class: Fastlane::Actions::IpaAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::IpaAction
- Defined in:
- lib/fastlane/actions/ipa.rb
Class Method Summary collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .fill_in_default_values(params) ⇒ Object
- .find_dsym_file(dir) ⇒ Object
- .find_ipa_file(dir) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .params_to_build_args(config) ⇒ Object
- .run(params) ⇒ Object
Methods inherited from Fastlane::Action
Class Method Details
.author ⇒ Object
212 213 214 |
# File 'lib/fastlane/actions/ipa.rb', line 212 def self. "joshdholtz" end |
.available_options ⇒ Object
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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/fastlane/actions/ipa.rb', line 146 def self. [ FastlaneCore::ConfigItem.new(key: :workspace, env_name: "IPA_WORKSPACE", description: "WORKSPACE Workspace (.xcworkspace) file to use to build app (automatically detected in current directory)", optional: true), FastlaneCore::ConfigItem.new(key: :project, env_name: "IPA_PROJECT", description: "Project (.xcodeproj) file to use to build app (automatically detected in current directory, overridden by --workspace option, if passed)", optional: true), FastlaneCore::ConfigItem.new(key: :configuration, env_name: "IPA_CONFIGURATION", description: "Configuration used to build", optional: true), FastlaneCore::ConfigItem.new(key: :scheme, env_name: "IPA_SCHEME", description: "Scheme used to build app", optional: true), FastlaneCore::ConfigItem.new(key: :clean, env_name: "IPA_CLEAN", description: "Clean project before building", optional: true, is_string: false), FastlaneCore::ConfigItem.new(key: :archive, env_name: "IPA_ARCHIVE", description: "Archive project after building", optional: true, is_string: false), FastlaneCore::ConfigItem.new(key: :destination, env_name: "IPA_DESTINATION", description: "Build destination. Defaults to current directory", optional: true), FastlaneCore::ConfigItem.new(key: :embed, env_name: "IPA_EMBED", description: "Sign .ipa file with .mobileprovision", optional: true), FastlaneCore::ConfigItem.new(key: :identity, env_name: "IPA_IDENTITY", description: "Identity to be used along with --embed", optional: true), FastlaneCore::ConfigItem.new(key: :sdk, env_name: "IPA_SDK", description: "Use SDK as the name or path of the base SDK when building the project", optional: true), FastlaneCore::ConfigItem.new(key: :ipa, env_name: "IPA_IPA", description: "Specify the name of the .ipa file to generate (including file extension)", optional: true), FastlaneCore::ConfigItem.new(key: :xcconfig, env_name: "IPA_XCCONFIG", description: "Use an extra XCCONFIG file to build the app", optional: true), FastlaneCore::ConfigItem.new(key: :xcargs, env_name: "IPA_XCARGS", description: "Pass additional arguments to xcodebuild when building the app. Be sure to quote multiple args", optional: true), ] end |
.description ⇒ Object
136 137 138 |
# File 'lib/fastlane/actions/ipa.rb', line 136 def self.description "Easily build and sign your app using shenzhen" end |
.details ⇒ Object
140 141 142 143 144 |
# File 'lib/fastlane/actions/ipa.rb', line 140 def self.details [ "More information on the shenzhen project page: https://github.com/nomad/shenzhen" ].join(' ') end |
.fill_in_default_values(params) ⇒ Object
120 121 122 123 124 |
# File 'lib/fastlane/actions/ipa.rb', line 120 def self.fill_in_default_values(params) = Actions.lane_context[Actions::SharedValues::SIGH_PROFILE_PATH] || ENV["SIGH_PROFILE_PATH"] params[:embed] ||= if params end |
.find_dsym_file(dir) ⇒ Object
131 132 133 134 |
# File 'lib/fastlane/actions/ipa.rb', line 131 def self.find_dsym_file(dir) # Finds last modified .dSYM.zip in the destination directory Dir[File.join(dir, '*.dSYM.zip')].sort { |a, b| File.mtime(b) <=> File.mtime(a) }.first end |
.find_ipa_file(dir) ⇒ Object
126 127 128 129 |
# File 'lib/fastlane/actions/ipa.rb', line 126 def self.find_ipa_file(dir) # Finds last modified .ipa in the destination directory Dir[File.join(dir, '*.ipa')].sort { |a, b| File.mtime(b) <=> File.mtime(a) }.first end |
.is_supported?(platform) ⇒ Boolean
26 27 28 |
# File 'lib/fastlane/actions/ipa.rb', line 26 def self.is_supported?(platform) platform == :ios end |
.output ⇒ Object
205 206 207 208 209 210 |
# File 'lib/fastlane/actions/ipa.rb', line 205 def self.output [ ['IPA_OUTPUT_PATH', 'The path to the newly generated ipa file'], ['DSYM_OUTPUT_PATH', 'The path to the dsym file'] ] end |
.params_to_build_args(config) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/fastlane/actions/ipa.rb', line 98 def self.params_to_build_args(config) params = config.values params = params.delete_if { |k, v| v.nil? } params = fill_in_default_values(params) # Maps nice developer param names to Shenzhen's `ipa build` arguments params.collect do |k, v| v ||= '' if args = ARGS_MAP[k] if k == :clean v == true ? '--clean' : '--no-clean' elsif k == :archive v == true ? '--archive' : nil else value = (v.to_s.length > 0 ? "\"#{v}\"" : '') "#{ARGS_MAP[k]} #{value}".strip end end end.compact end |
.run(params) ⇒ Object
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 |
# File 'lib/fastlane/actions/ipa.rb', line 31 def self.run(params) # The args we will build with build_args = nil # The output directory of the IPA and dSYM absolute_dest_directory = nil # Used to get the final path of the IPA and dSYM if dest = params[:destination] absolute_dest_directory = Dir.glob(dest).map(&File.method(:realpath)).first end # Maps nice developer build parameters to Shenzhen args build_args = params_to_build_args(params) unless (params[:scheme] rescue nil) Helper.log.warn "You haven't specified a scheme. This might cause problems. If you can't see any output, please pass a `scheme`" end # If no dest directory given, default to current directory absolute_dest_directory ||= Dir.pwd if Helper.test? Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] = File.join(absolute_dest_directory, 'test.ipa') Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] = File.join(absolute_dest_directory, 'test.app.dSYM.zip') return build_args end # Joins args into space delimited string build_args = build_args.join(' ') core_command = "krausefx-ipa build #{build_args} --verbose | xcpretty" command = "set -o pipefail && #{core_command}" Helper.log.debug command begin Actions.sh command # Finds absolute path of IPA and dSYM absolute_ipa_path = find_ipa_file(absolute_dest_directory) absolute_dsym_path = find_dsym_file(absolute_dest_directory) # Sets shared values to use after this action is performed Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] = absolute_ipa_path Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] = absolute_dsym_path ENV[SharedValues::IPA_OUTPUT_PATH.to_s] = absolute_ipa_path # for deliver ENV[SharedValues::DSYM_OUTPUT_PATH.to_s] = absolute_dsym_path rescue => ex [ "-------------------------------------------------------", "Original Error:", " => " + ex.to_s, "A build error occured. This can have many reasons, usually", "it has something to do with code signing. The `ipa` action", "uses `shenzhen` under the hood: https://github.com/nomad/shenzhen", "The command that was used by fastlane:", core_command, "-------------------------------------------------------" ].each do |txt| Helper.log.error txt.yellow end # Raise a custom exception, as the the normal one is useless for the user raise "A build error occured, this is usually related to code signing. Take a look at the error above".red end end |