snapshot 1.12.1 → 1.12.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5403d3a85b61bd0cd8036fd1fdb3c75dba4c64a7
4
- data.tar.gz: 504b5e471e8188c7b89fa4da81c2739e17045909
3
+ metadata.gz: f66739b39604b0850729cdbc3ec8b7c285b8dc0d
4
+ data.tar.gz: a724757422b90bd6b7c438d2550322d0c19422fc
5
5
  SHA512:
6
- metadata.gz: 7993f66ee0575507b64de582d8cb7df939386643a821a186b20a9ea16046a63cb00f52639f19b107919633a91029d3c789f9b84b4fb3948a101cd85c3c475302
7
- data.tar.gz: 4ddfccd5e70643ed187f1f6fd67cb7d4bb54b231382e985ff0efba85935516cb16a2ab4471dc2d437b1f7fffac675db5d80deb86399fb08f75662d35de1516aa
6
+ metadata.gz: 6ea43999e4268e07952c39b1788e35ff0609d150d10e6ef71eda5b556aea4368f51270039caf0928d596f532b1a575fa298a168744688e8252b6039aa9887f5c
7
+ data.tar.gz: 87eb051ee9eee593b5e264426c7caa810bc3077cc7909a92f245b53f65a8741701dea62037bfbb7a15addff8d556cd146d1b22b4b93e2481985c3cfda35a141c
data/README.md CHANGED
@@ -81,7 +81,7 @@ Please check out the [MigrationGuide to 1.0](/snapshot/MigrationGuide.md) :+1:
81
81
 
82
82
  -------
83
83
 
84
- <h5 align="center"><code>snapshot</code> is part of <a href="https://fastlane.tools">fastlane</a>: connect all deployment tools into one streamlined workflow.</h5>
84
+ <h5 align="center"><code>snapshot</code> is part of <a href="https://fastlane.tools">fastlane</a>: The easiest way to automate building and releasing your iOS and Android apps.</h5>
85
85
 
86
86
  # Features
87
87
  - Create hundreds of screenshots in multiple languages on all simulators
@@ -329,7 +329,7 @@ When the user calls `snapshot(...)` in the UI Tests (Swift or Objective C) the s
329
329
 
330
330
  In the test output, the Swift `snapshot` function will print out something like this
331
331
 
332
- snapshot: [some random text here]
332
+ > snapshot: [some random text here]
333
333
 
334
334
  `snapshot` finds all these entries using a regex. The number of `snapshot` outputs in the terminal and the number of `snapshot` events in the plist file should be the same. Knowing that, `snapshot` automatically matches these 2 lists to identify the name of each of these screenshots. They are then copied over to the output directory and separated by language and device.
335
335
 
@@ -346,7 +346,7 @@ Also, feel free to duplicate radar [23062925](https://openradar.appspot.com/rada
346
346
 
347
347
  ## [`fastlane`](https://fastlane.tools) Toolchain
348
348
 
349
- - [`fastlane`](https://fastlane.tools): Connect all deployment tools into one streamlined workflow
349
+ - [`fastlane`](https://fastlane.tools): The easiest way to automate building and releasing your iOS and Android apps
350
350
  - [`deliver`](https://github.com/fastlane/fastlane/tree/master/deliver): Upload screenshots, metadata and your app to the App Store
351
351
  - [`frameit`](https://github.com/fastlane/fastlane/tree/master/frameit): Quickly put your screenshots into the right device frames
352
352
  - [`PEM`](https://github.com/fastlane/fastlane/tree/master/pem): Automatically generate and renew your push notification profiles
@@ -25,9 +25,9 @@ func snapshot(name: String, waitForLoadingIndicator: Bool = true) {
25
25
  Snapshot.snapshot(name, waitForLoadingIndicator: waitForLoadingIndicator)
26
26
  }
27
27
 
28
- class Snapshot: NSObject {
28
+ public class Snapshot: NSObject {
29
29
 
30
- class func setupSnapshot(app: XCUIApplication) {
30
+ public class func setupSnapshot(app: XCUIApplication) {
31
31
  setLanguage(app)
32
32
  setLocale(app)
33
33
  setLaunchArguments(app)
@@ -89,7 +89,7 @@ class Snapshot: NSObject {
89
89
  }
90
90
  }
91
91
 
92
- class func snapshot(name: String, waitForLoadingIndicator: Bool = true) {
92
+ public class func snapshot(name: String, waitForLoadingIndicator: Bool = true) {
93
93
  if waitForLoadingIndicator {
94
94
  waitForLoadingIndicatorToDisappear()
95
95
  }
@@ -5,8 +5,6 @@ module Snapshot
5
5
 
6
6
  class HardwareKeyboardFix
7
7
  def self.patch
8
- Snapshot.kill_simulator # First we need to kill the simulator
9
-
10
8
  UI.verbose "Patching simulator to work with secure text fields"
11
9
 
12
10
  Helper.backticks("defaults write com.apple.iphonesimulator ConnectHardwareKeyboard 0", print: $verbose)
@@ -7,8 +7,6 @@ module Snapshot
7
7
 
8
8
  class SimulatorZoomFix
9
9
  def self.patch
10
- Snapshot.kill_simulator # First we need to kill the simulator
11
-
12
10
  UI.message "Patching '#{config_path}' to scale simulator to 100%"
13
11
 
14
12
  FastlaneCore::Simulator.all.each do |simulator|
@@ -14,11 +14,11 @@ module Snapshot
14
14
 
15
15
  matched = output.match(/iOS ([\d\.]+) \(.*/)
16
16
  if matched.nil?
17
- raise "Could not determine installed iOS SDK version. Try running the _xcodebuild_ command manually to ensure it works."
17
+ UI.user_error!("Could not determine installed iOS SDK version. Try running the _xcodebuild_ command manually to ensure it works.")
18
18
  elsif matched.length > 1
19
19
  return @version ||= matched[1]
20
20
  else
21
- raise "Could not determine installed iOS SDK version. Please pass it via the environment variable 'SNAPSHOT_IOS_VERSION'".red
21
+ UI.user_error!("Could not determine installed iOS SDK version. Please pass it via the environment variable 'SNAPSHOT_IOS_VERSION'")
22
22
  end
23
23
  end
24
24
  end
@@ -14,9 +14,9 @@ module Snapshot
14
14
  description: "Path the workspace file",
15
15
  verify_block: proc do |value|
16
16
  v = File.expand_path(value.to_s)
17
- raise "Workspace file not found at path '#{v}'".red unless File.exist?(v)
18
- raise "Workspace file invalid".red unless File.directory?(v)
19
- raise "Workspace file is not a workspace, must end with .xcworkspace".red unless v.include?(".xcworkspace")
17
+ UI.user_error!("Workspace file not found at path '#{v}'") unless File.exist?(v)
18
+ UI.user_error!("Workspace file invalid") unless File.directory?(v)
19
+ UI.user_error!("Workspace file is not a workspace, must end with .xcworkspace") unless v.include?(".xcworkspace")
20
20
  end),
21
21
  FastlaneCore::ConfigItem.new(key: :project,
22
22
  short_option: "-p",
@@ -25,9 +25,9 @@ module Snapshot
25
25
  description: "Path the project file",
26
26
  verify_block: proc do |value|
27
27
  v = File.expand_path(value.to_s)
28
- raise "Project file not found at path '#{v}'".red unless File.exist?(v)
29
- raise "Project file invalid".red unless File.directory?(v)
30
- raise "Project file is not a project file, must end with .xcodeproj".red unless v.include?(".xcodeproj")
28
+ UI.user_error!("Project file not found at path '#{v}'") unless File.exist?(v)
29
+ UI.user_error!("Project file invalid") unless File.directory?(v)
30
+ UI.user_error!("Project file is not a project file, must end with .xcodeproj") unless v.include?(".xcodeproj")
31
31
  end),
32
32
  FastlaneCore::ConfigItem.new(key: :devices,
33
33
  description: "A list of devices you want to take the screenshots from",
@@ -38,7 +38,7 @@ module Snapshot
38
38
  available = FastlaneCore::Simulator.all
39
39
  value.each do |current|
40
40
  unless available.any? { |d| d.name.strip == current.strip }
41
- raise "Device '#{current}' not in list of available simulators '#{available.join(', ')}'".red
41
+ UI.user_error!("Device '#{current}' not in list of available simulators '#{available.join(', ')}'")
42
42
  end
43
43
  end
44
44
  end),
@@ -82,6 +82,11 @@ module Snapshot
82
82
  description: "Enabling this option will automatically erase the simulator before running the application",
83
83
  default_value: false,
84
84
  is_string: false),
85
+ FastlaneCore::ConfigItem.new(key: :localize_simulator,
86
+ env_name: 'SNAPSHOT_LOCALIZE_SIMULATOR',
87
+ description: "Enabling this option will configure the Simulator's system language",
88
+ default_value: false,
89
+ is_string: false),
85
90
  FastlaneCore::ConfigItem.new(key: :app_identifier,
86
91
  env_name: 'SNAPSHOT_APP_IDENTIFIER',
87
92
  short_option: "-a",
@@ -7,7 +7,7 @@ module Snapshot
7
7
 
8
8
  sure = true if ENV["SNAPSHOT_FORCE_DELETE"]
9
9
  sure = agree("Are you sure? All your simulators will be DELETED and new ones will be created! (y/n)".red, true) unless sure
10
- raise "User cancelled action" unless sure
10
+ UI.user_error!("User cancelled action") unless sure
11
11
 
12
12
  devices.each do |device|
13
13
  _, name, id = device
@@ -123,14 +123,19 @@ module Snapshot
123
123
  File.write(File.join(prefix, "locale.txt"), locale || "")
124
124
  File.write(File.join(prefix, "snapshot-launch_arguments.txt"), launch_arguments.last)
125
125
 
126
- Fixes::SimulatorZoomFix.patch
127
- Fixes::HardwareKeyboardFix.patch
128
-
126
+ # Kill and shutdown all currently running simulators so that the following settings
127
+ # changes will be picked up when they are started again.
129
128
  Snapshot.kill_simulator # because of https://github.com/fastlane/snapshot/issues/337
130
129
  `xcrun simctl shutdown booted &> /dev/null`
131
130
 
132
- if Snapshot.config[:erase_simulator]
131
+ Fixes::SimulatorZoomFix.patch
132
+ Fixes::HardwareKeyboardFix.patch
133
+
134
+ if Snapshot.config[:erase_simulator] || Snapshot.config[:localize_simulator]
133
135
  erase_simulator(device_type)
136
+ if Snapshot.config[:localize_simulator]
137
+ localize_simulator(device_type, language, locale)
138
+ end
134
139
  elsif Snapshot.config[:reinstall_app]
135
140
  # no need to reinstall if device has been erased
136
141
  uninstall_app(device_type)
@@ -139,6 +144,8 @@ module Snapshot
139
144
  add_media(device_type, :photo, Snapshot.config[:add_photos]) if Snapshot.config[:add_photos]
140
145
  add_media(device_type, :video, Snapshot.config[:add_videos]) if Snapshot.config[:add_videos]
141
146
 
147
+ open_simulator_for_device(device_type)
148
+
142
149
  command = TestCommandGenerator.generate(device_type: device_type)
143
150
 
144
151
  if locale
@@ -183,6 +190,13 @@ module Snapshot
183
190
  return Collector.fetch_screenshots(raw_output, dir_name, device_type, launch_arguments.first)
184
191
  end
185
192
 
193
+ def open_simulator_for_device(device)
194
+ return unless ENV['FASTLANE_EXPLICIT_OPEN_SIMULATOR']
195
+
196
+ UI.message("Explicitly opening simulator for device: #{device}")
197
+ `open -a Simulator --args -CurrentDeviceUDID #{TestCommandGenerator.device_udid(device)}`
198
+ end
199
+
186
200
  def uninstall_app(device_type)
187
201
  UI.verbose "Uninstalling app '#{Snapshot.config[:app_identifier]}' from #{device_type}..."
188
202
  Snapshot.config[:app_identifier] ||= ask("App Identifier: ")
@@ -196,14 +210,28 @@ module Snapshot
196
210
  end
197
211
 
198
212
  def erase_simulator(device_type)
199
- Helper.log.debug "Erasing #{device_type}..."
213
+ UI.verbose("Erasing #{device_type}...")
200
214
  device_udid = TestCommandGenerator.device_udid(device_type)
201
215
 
202
- Helper.log.info "Erasing #{device_type}...".yellow
216
+ UI.important("Erasing #{device_type}...")
203
217
 
204
218
  `xcrun simctl erase #{device_udid} &> /dev/null`
205
219
  end
206
220
 
221
+ def localize_simulator(device_type, language, locale)
222
+ device_udid = TestCommandGenerator.device_udid(device_type)
223
+ if device_udid
224
+ locale ||= language.sub("-", "_")
225
+ plist = {
226
+ AppleLocale: locale,
227
+ AppleLanguages: [language]
228
+ }
229
+ UI.message "Localizing #{device_type} (AppleLocale=#{locale} AppleLanguages=[#{language}])"
230
+ plist_path = "#{ENV['HOME']}/Library/Developer/CoreSimulator/Devices/#{device_udid}/data/Library/Preferences/.GlobalPreferences.plist"
231
+ File.write(plist_path, Plist::Emit.dump(plist))
232
+ end
233
+ end
234
+
207
235
  def add_media(device_type, media_type, paths)
208
236
  media_type = media_type.to_s
209
237
 
@@ -5,7 +5,7 @@ module Snapshot
5
5
  snapfile_path = File.join(path, 'Snapfile')
6
6
 
7
7
  if File.exist?(snapfile_path)
8
- raise "Snapfile already exists at path '#{snapfile_path}'. Run 'snapshot' to use snapshot.".red
8
+ UI.user_error!("Snapfile already exists at path '#{snapfile_path}'. Run 'snapshot' to use snapshot.")
9
9
  end
10
10
 
11
11
  gem_path = Helper.gem_path("snapshot")
@@ -24,7 +24,7 @@ module Snapshot
24
24
  def project_path_array
25
25
  proj = Snapshot.project.xcodebuild_parameters
26
26
  return proj if proj.count > 0
27
- raise "No project/workspace found"
27
+ UI.user_error!("No project/workspace found")
28
28
  end
29
29
 
30
30
  def options
@@ -1,4 +1,4 @@
1
1
  module Snapshot
2
- VERSION = "1.12.1".freeze
2
+ VERSION = "1.12.2".freeze
3
3
  DESCRIPTION = "Automate taking localized screenshots of your iOS app on every device"
4
4
  end
data/lib/snapshot.rb CHANGED
@@ -38,7 +38,8 @@ module Snapshot
38
38
  end
39
39
 
40
40
  def kill_simulator
41
- `killall iOS Simulator &> /dev/null`
41
+ `killall 'iOS Simulator' &> /dev/null`
42
+ `killall Simulator &> /dev/null`
42
43
  end
43
44
  end
44
45
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.1
4
+ version: 1.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-22 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastimage