Class: Fastlane::Actions::BuildAppForIosSimulatorAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::BuildAppForIosSimulatorAction
- Defined in:
- lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb
Class Method Summary collapse
- .available_destinations ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .clean(params) ⇒ Object
- .copy_app(params) ⇒ Object
-
.description ⇒ Object
Documentation #.
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .products_path(params) ⇒ Object
- .provide_shared_values(path) ⇒ Object
- .run(params) ⇒ Object
- .update_xcargs(params) ⇒ Object
- .verify_destination(params) ⇒ Object
Class Method Details
.available_destinations ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 119 def self.available_destinations { iOS: { destination: 'iOS Simulator', folder: 'iphonesimulator' }, tvOS: { destination: 'tvOS Simulator', folder: 'appletvsimulator' }, watchOS: { destination: 'watchOS Simulator', folder: 'applewatchsimulator' } } end |
.available_options ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 157 def self. XcodebuildAction. + [ ['output_directory', 'The directory in which the app file should be stored in'], ['workspace', 'Path to the workspace file'], ['project', 'Path to the project file'], ['scheme', "The project's scheme. Make sure it's marked as `Shared`"], ['platform', "Use a custom simulator destination for building the app (iOS, tvOS or watchOS)"], ['configuration', 'The configuration to use when building the app. Defaults to "Debug"'], ['derived_data_path', 'The directory where built products and other derived data will go'], ['result_bundle_path', 'Path to the result bundle directory to create'], ['buildlog_path', 'The directory where to store the build log'], ['raw_buildlog', 'Set to true to see xcodebuild raw output'], ['xcargs', "Pass additional xcodebuild options. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS='-ObjC -lstdc++'"] ] end |
.category ⇒ Object
173 174 175 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 173 def self.category :building end |
.clean(params) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 25 def self.clean(params) if params[:output_directory] FastlaneCore::UI.important('๐งน Clearing output directory.') FileUtils.rm_rf(params[:output_directory]) end path = "./#{params[:scheme]}.app" if File.directory?(path) FastlaneCore::UI.important('๐งน Removing previous build.') FileUtils.rm_rf(path) end path = "build/#{params[:scheme]}.app" if File.directory?(path) FastlaneCore::UI.important('๐งน Removing previous build.') FileUtils.rm_rf(path) end end |
.copy_app(params) ⇒ Object
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 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 67 def self.copy_app(params) platform = available_destinations[params[:platform]][:folder] postfix = "#{params[:configuration]}-#{platform}/#{params[:scheme]}.app" products_path = products_path(params) products_app_path = if params[:project] "#{File.dirname(File.(params[:project]))}/#{products_path}/#{postfix}" elsif params[:workspace] "#{File.dirname(File.(params[:workspace]))}/#{products_path}/#{postfix}" else "#{Dir.pwd}/#{products_path}/#{postfix}" end derived_data_app_path = if params[:derived_data_path] "#{params[:derived_data_path]}/Build/Products/#{postfix}" else "#{Dir.pwd}/#{products_path}/Build/Products/#{postfix}" end app_path = File.directory?(derived_data_app_path) ? derived_data_app_path : products_app_path new_path = if params[:output_directory] FileUtils.mkdir_p(params[:output_directory]) FileUtils.cp_r(app_path, params[:output_directory]) "#{params[:output_directory]}/#{params[:scheme]}.app" else FileUtils.rm_rf("#{params[:scheme]}.app") FileUtils.cp_r(app_path, './') "./#{params[:scheme]}.app" end File.(new_path) end |
.description ⇒ Object
Documentation #
136 137 138 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 136 def self.description "This plugin builds apps exclusively for iOS, tvOS or watchOS Simulators." end |
.example_code ⇒ Object
140 141 142 143 144 145 146 147 148 149 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 140 def self.example_code [ build_app_for_simulator( scheme: 'sample-app', project: 'sample-app/sample-app.xcodeproj', configuration: 'Release', output_directory: 'build' ) ] end |
.is_supported?(platform) ⇒ Boolean
177 178 179 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 177 def self.is_supported?(platform) [:ios, :tvos, :watchos].include?(platform) end |
.output ⇒ Object
151 152 153 154 155 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 151 def self.output [ ['SIMULATOR_APP_OUTPUT_PATH', 'The path to the newly generated app file'] ] end |
.products_path(params) ⇒ Object
63 64 65 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 63 def self.products_path(params) params[:output_directory] || 'build' end |
.provide_shared_values(path) ⇒ Object
127 128 129 130 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 127 def self.provide_shared_values(path) Actions.lane_context[SharedValues::SIMULATOR_APP_OUTPUT_PATH] = File.(path) ENV[SharedValues::SIMULATOR_APP_OUTPUT_PATH.to_s] = File.(path) end |
.run(params) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 8 def self.run(params) params[:platform] = verify_destination(params) params[:xcargs] = update_xcargs(params) params[:archive] = nil if params[:archive] params[:configuration] = 'Debug' unless params[:configuration] params[:derivedDataPath] = params[:derived_data_path] if params[:derived_data_path] clean(params) XcodebuildAction.run(params) new_path = copy_app(params) provide_shared_values(new_path) new_path end |
.update_xcargs(params) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 44 def self.update_xcargs(params) if params[:xcargs] && params[:xcargs].include?('destination') FastlaneCore::UI.important( '๐ญ Overwriting `xcargs` option for safety reasons. Consider excluding `-destination` argument from it.' ) params[:xcargs] = '' end platform = available_destinations[params[:platform]][:destination] destination = "-destination 'generic/platform=#{platform}'" products_path = "-IDECustomBuildProductsPath='#{products_path(params)}'" if params[:derived_data_path] "#{params[:xcargs]} #{products_path} #{destination}" else derived_data_path = "-derivedDataPath '#{products_path(params)}'" "#{params[:xcargs]} #{products_path} #{destination} #{derived_data_path}" end end |
.verify_destination(params) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb', line 104 def self.verify_destination(params) case params[:platform] when 'iOS', nil :iOS when 'tvOS' :tvOS when 'watchOS' :watchOS else FastlaneCore::UI.user_error!( "๐ฌ Unrecognized platform: '#{params[:platform]}'. Available: 'iOS', 'tvOS' and 'watchOS'" ) end end |