fastlane-plugin-build_app_for_simulator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c42d17b51edca770b9ddf685fd7c4a2ee4579908bdbb38a37922b598860771f4
4
+ data.tar.gz: dc2f6a66809aeb60fc281bf538a9fcc6552c5c1131def52b0c1271021a7ff4ea
5
+ SHA512:
6
+ metadata.gz: 852d571b3ebae7573fd1593f76efeda0e5cc79dbdbe1ee0b51a60b95ceab14ac84d22280df04e1500e28f1c5f30992c2d0355ab8df3f1eb468dbbb13c90969f1
7
+ data.tar.gz: 386a0d2ca76ac0801f7670f0063e295335da597406e49d93497b32bd3f35c63ef2b683a603a224a30cdf950927c32645ae63d0007cc85bb146897da240db3690
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Alexey Alter-Pesotskiy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # fastlane-plugin-build_app_for_simulator
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-build_app_for_simulator)
4
+
5
+ ## About build_app_for_simulator
6
+
7
+ This plugin builds apps exclusively for iOS, tvOS or watchOS Simulators 🚀
8
+
9
+ ## Parameters
10
+
11
+ | **Key** | **Description** | **Default** |
12
+ | ------- |---------------- | ----------- |
13
+ | `output_directory` | The directory in which the app file should be stored in | `.` |
14
+ | `workspace` | Path to the workspace file | |
15
+ | `project` | Path to the project file | |
16
+ | `scheme` | The project's scheme. Make sure it's marked as `Shared` | |
17
+ | `platform` | Use a custom simulator destination for building the app (`iOS`, `tvOS` or `watchOS`) | `iOS` |
18
+ | `configuration` | The configuration to use when building the app | `Debug` |
19
+ | `derived_data_path` | The directory where built products and other derived data will go | |
20
+ | `result_bundle_path` | Path to the result bundle directory to create | |
21
+ | `buildlog_path` | The directory where to store the build log | |
22
+ | `raw_buildlog` | Set to `true` to see xcodebuild raw output | `false` |
23
+ | `xcargs` | Pass additional xcodebuild options. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS='-ObjC -lstdc++' | |
24
+
25
+ ## Requirements
26
+
27
+ * [Xcode](https://developer.apple.com/downloads)
28
+ * [Xcode Command Line Tools](http://railsapps.github.io/xcode-command-line-tools.html)
29
+
30
+ ## Getting Started
31
+
32
+ To get started with `build_app_for_simulator`, add it to your project by running:
33
+
34
+ ```bash
35
+ $ fastlane add_plugin build_app_for_simulator
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```ruby
41
+ build_app_for_simulator(
42
+ scheme: 'AppName',
43
+ workspace: 'Example.xcworkspace',
44
+ configuration: 'Release',
45
+ output_directory: 'build'
46
+ )
47
+ ```
48
+
49
+ ## Lane Variables
50
+
51
+ | **SharedValue** | **Description** |
52
+ | --------------------------------------- | ---------------------------------------- |
53
+ | SharedValues::SIMULATOR_APP_OUTPUT_PATH | The path to the newly generated app file |
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/build_app_for_simulator/version'
2
+
3
+ module Fastlane
4
+ module BuildAppForSimulator
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::BuildAppForSimulator.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,187 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/actions/xcodebuild'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ SIMULATOR_APP_OUTPUT_PATH ||= :SIMULATOR_APP_OUTPUT_PATH
8
+ end
9
+
10
+ class BuildAppForSimulatorAction < Action
11
+ def self.run(params)
12
+ params[:platform] = verify_destination(params)
13
+ params[:xcargs] = update_xcargs(params)
14
+ params[:archive] = nil if params[:archive]
15
+ params[:configuration] = 'Debug' unless params[:configuration]
16
+ params[:derivedDataPath] = params[:derived_data_path] if params[:derived_data_path]
17
+
18
+ clean(params)
19
+
20
+ XcodebuildAction.run(params)
21
+
22
+ new_path = copy_app(params)
23
+
24
+ provide_shared_values(new_path)
25
+ end
26
+
27
+ def self.clean(params)
28
+ if params[:output_directory]
29
+ FastlaneCore::UI.important('🧹 Clearing output directory.')
30
+ FileUtils.rm_rf(params[:output_directory])
31
+ end
32
+
33
+ path = "./#{params[:scheme]}.app"
34
+ if File.directory?(path)
35
+ FastlaneCore::UI.important('🧹 Removing previous build.')
36
+ FileUtils.rm_rf(path)
37
+ end
38
+
39
+ path = "build/#{params[:scheme]}.app"
40
+ if File.directory?(path)
41
+ FastlaneCore::UI.important('🧹 Removing previous build.')
42
+ FileUtils.rm_rf(path)
43
+ end
44
+ end
45
+
46
+ def self.update_xcargs(params)
47
+ if params[:xcargs] && params[:xcargs].include?('destination')
48
+ FastlaneCore::UI.important(
49
+ '🎭 Overwriting `xcargs` option for safety reasons. Consider excluding `-destination` argument from it.'
50
+ )
51
+ params[:xcargs] = ''
52
+ end
53
+
54
+ platform = available_destinations[params[:platform]][:destination]
55
+ destination = "-destination 'generic/platform=#{platform}'"
56
+ products_path = "-IDECustomBuildProductsPath='#{products_path(params)}'"
57
+ if params[:derived_data_path]
58
+ "#{params[:xcargs]} #{products_path} #{destination}"
59
+ else
60
+ derived_data_path = "-derivedDataPath '#{products_path(params)}'"
61
+ "#{params[:xcargs]} #{products_path} #{destination} #{derived_data_path}"
62
+ end
63
+ end
64
+
65
+ def self.products_path(params)
66
+ params[:output_directory] ? params[:output_directory] : 'build'
67
+ end
68
+
69
+ def self.copy_app(params)
70
+ platform = available_destinations[params[:platform]][:folder]
71
+ postfix = "#{params[:configuration]}-#{platform}/#{params[:scheme]}.app"
72
+ products_path = products_path(params)
73
+
74
+ products_app_path =
75
+ if params[:project]
76
+ "#{File.dirname(File.expand_path(params[:project]))}/#{products_path}/#{postfix}"
77
+ elsif params[:workspace]
78
+ "#{File.dirname(File.expand_path(params[:workspace]))}/#{products_path}/#{postfix}"
79
+ else
80
+ "#{Dir.pwd}/#{products_path}/#{postfix}"
81
+ end
82
+
83
+ derived_data_app_path =
84
+ if params[:derived_data_path]
85
+ "#{params[:derived_data_path]}/Build/Products/#{postfix}"
86
+ else
87
+ "#{Dir.pwd}/#{products_path}/Build/Products/#{postfix}"
88
+ end
89
+
90
+ app_path = File.directory?(derived_data_app_path) ? derived_data_app_path : products_app_path
91
+
92
+ if params[:output_directory]
93
+ FileUtils.mkdir_p(params[:output_directory])
94
+ FileUtils.cp_r(app_path, params[:output_directory])
95
+ "#{params[:output_directory]}/#{params[:scheme]}.app"
96
+ else
97
+ FileUtils.rm_rf("#{params[:scheme]}.app")
98
+ FileUtils.cp_r(app_path, './')
99
+ "./#{params[:scheme]}.app"
100
+ end
101
+ end
102
+
103
+ def self.verify_destination(params)
104
+ case params[:platform]
105
+ when 'iOS'
106
+ :iOS
107
+ when 'tvOS'
108
+ :tvOS
109
+ when 'watchOS'
110
+ :watchOS
111
+ when nil
112
+ :iOS
113
+ else
114
+ FastlaneCore::UI.user_error!(
115
+ "🔬 Unrecognized platform: '#{params[:platform]}'. Available: 'iOS', 'tvOS' and 'watchOS'"
116
+ )
117
+ end
118
+ end
119
+
120
+ def self.available_destinations
121
+ {
122
+ iOS: { destination: 'iOS Simulator', folder: 'iphonesimulator' },
123
+ tvOS: { destination: 'tvOS Simulator', folder: 'appletvsimulator' },
124
+ watchOS: { destination: 'watchOS Simulator', folder: 'applewatchsimulator' }
125
+ }
126
+ end
127
+
128
+ def self.provide_shared_values(path)
129
+ Actions.lane_context[SharedValues::SIMULATOR_APP_OUTPUT_PATH] = File.expand_path(path)
130
+ ENV[SharedValues::SIMULATOR_APP_OUTPUT_PATH.to_s] = File.expand_path(path)
131
+ end
132
+
133
+ #####################################################
134
+ # Documentation #
135
+ #####################################################
136
+
137
+ def self.description
138
+ "This plugin builds apps exclusively for iOS, tvOS or watchOS Simulators."
139
+ end
140
+
141
+ def self.example_code
142
+ [
143
+ build_app_for_simulator(
144
+ scheme: 'sample-app',
145
+ project: 'sample-app/sample-app.xcodeproj',
146
+ configuration: 'Release',
147
+ output_directory: 'build'
148
+ )
149
+ ]
150
+ end
151
+
152
+ def self.output
153
+ [
154
+ ['SIMULATOR_APP_OUTPUT_PATH', 'The path to the newly generated app file']
155
+ ]
156
+ end
157
+
158
+ def self.authors
159
+ ["alteral"]
160
+ end
161
+
162
+ def self.available_options
163
+ XcodebuildAction.available_options + [
164
+ ['output_directory', 'The directory in which the app file should be stored in'],
165
+ ['workspace', 'Path to the workspace file'],
166
+ ['project', 'Path to the project file'],
167
+ ['scheme', "The project's scheme. Make sure it's marked as `Shared`"],
168
+ ['platform', "Use a custom simulator destination for building the app (iOS, tvOS or watchOS)"],
169
+ ['configuration', 'The configuration to use when building the app. Defaults to "Release"'],
170
+ ['derived_data_path', 'The directory where built products and other derived data will go'],
171
+ ['result_bundle_path', 'Path to the result bundle directory to create'],
172
+ ['buildlog_path', 'The directory where to store the build log'],
173
+ ['raw_buildlog', 'Set to true to see xcodebuild raw output'],
174
+ ['xcargs', "Pass additional xcodebuild options. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS='-ObjC -lstdc++'"]
175
+ ]
176
+ end
177
+
178
+ def self.category
179
+ :building
180
+ end
181
+
182
+ def self.is_supported?(platform)
183
+ [:ios, :tvos, :watchos].include?(platform)
184
+ end
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module BuildAppForSimulator
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-build_app_for_simulator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexey Alter-Pesotskiy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fasterer
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.49.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.49.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-require_tools
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: fastlane
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 2.144.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 2.144.0
153
+ description:
154
+ email: a.alterpesotskiy@mail.ru
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/build_app_for_simulator.rb
162
+ - lib/fastlane/plugin/build_app_for_simulator/actions/build_app_for_simulator_action.rb
163
+ - lib/fastlane/plugin/build_app_for_simulator/version.rb
164
+ homepage: https://github.com/alteral/fastlane-plugin-build_app_for_simulator
165
+ licenses:
166
+ - MIT
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubygems_version: 3.0.3
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: This plugin builds apps exclusively for iOS, tvOS or watchOS Simulators.
187
+ test_files: []