snapshot 1.13.1 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -22
- data/lib/assets/SnapshotHelper.swift +11 -2
- data/lib/snapshot.rb +2 -1
- data/lib/snapshot/collector.rb +5 -2
- data/lib/snapshot/commands_generator.rb +1 -2
- data/lib/snapshot/dependency_checker.rb +1 -1
- data/lib/snapshot/detect_values.rb +19 -4
- data/lib/snapshot/fixes/simulator_zoom_fix.rb +1 -1
- data/lib/snapshot/latest_os_version.rb +31 -0
- data/lib/snapshot/options.rb +3 -3
- data/lib/snapshot/page.html.erb +1 -1
- data/lib/snapshot/reports_generator.rb +7 -6
- data/lib/snapshot/runner.rb +0 -4
- data/lib/snapshot/setup.rb +2 -3
- data/lib/snapshot/test_command_generator.rb +16 -7
- data/lib/snapshot/update.rb +2 -3
- data/lib/snapshot/version.rb +1 -1
- metadata +5 -5
- data/lib/snapshot/latest_ios_version.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 507d1a24a86968c2207b6b86b7f8d5dc855147c1
|
4
|
+
data.tar.gz: d96ff57e41e2ba04fe71820d84c3386862de0496
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fdcb712a94aa20a9dddc6d81f5b9c66992e63566d91016b348764a6c65ffad5a962d2ef7433552cbcce18f96efa1c0a565468f7e5aad5c2ff478e3d099137c9
|
7
|
+
data.tar.gz: 55eb482ca24372840bc655560cec79e4f2db0e2fb579891050912ceecb9ffb53e6e3c40bc3117f54f46d1eee01fbe558c5ece3789efe2eaf267aab9c306cea34
|
data/README.md
CHANGED
@@ -53,22 +53,6 @@ More information about [creating perfect screenshots](https://krausefx.com/blog/
|
|
53
53
|
|
54
54
|
Get in contact with the developer on Twitter: [@FastlaneTools](https://twitter.com/FastlaneTools)
|
55
55
|
|
56
|
-
### Note: New `snapshot` with UI Tests in Xcode 7
|
57
|
-
|
58
|
-
Apple announced a new version of Xcode with support for UI Tests built in right into Xcode. This technology allows `snapshot` to be even better: Instead of dealing with UI Automation Javascript code, you are now be able to write the screenshot code in Swift or Objective C allowing you to use debugging features like breakpoints.
|
59
|
-
|
60
|
-
As a result, `snapshot` was completely rewritten from ground up without changing its public API.
|
61
|
-
|
62
|
-
Please check out the [MigrationGuide to 1.0](/snapshot/MigrationGuide.md) :+1:
|
63
|
-
|
64
|
-
**Why change to UI Tests?**
|
65
|
-
|
66
|
-
- UI Automation is deprecated
|
67
|
-
- UI Tests will evolve and support even more features in the future
|
68
|
-
- UI Tests are much easier to debug
|
69
|
-
- UI Tests are written in Swift or Objective C
|
70
|
-
- UI Tests can be executed in a much cleaner and better way
|
71
|
-
|
72
56
|
-------
|
73
57
|
<p align="center">
|
74
58
|
<a href="#features">Features</a> •
|
@@ -126,7 +110,7 @@ Make sure, you have the latest version of the Xcode command line tools installed
|
|
126
110
|
# UI Tests
|
127
111
|
|
128
112
|
## Getting started
|
129
|
-
This project uses Apple's newly announced UI Tests.
|
113
|
+
This project uses Apple's newly announced UI Tests. We will not go into detail on how to write scripts.
|
130
114
|
|
131
115
|
Here a few links to get started:
|
132
116
|
|
@@ -136,8 +120,6 @@ Here a few links to get started:
|
|
136
120
|
- [HSTestingBackchannel : ‘Cheat’ by communicating directly with your app](https://github.com/ConfusedVorlon/HSTestingBackchannel)
|
137
121
|
- [Automating App Store screenshots using fastlane snapshot and frameit](https://tisunov.github.io/2015/11/06/automating-app-store-screenshots-generation-with-fastlane-snapshot-and-sketch.html)
|
138
122
|
|
139
|
-
**Note**: Since there is no official way to trigger a screenshot from UI Tests, `snapshot` uses a workaround (described in [How Does It Work?](#how-does-it-work)) to trigger a screenshot. If you feel like this should be done right, please duplicate radar [23062925](https://openradar.appspot.com/radar?id=5056366381105152).
|
140
|
-
|
141
123
|
# Quick Start
|
142
124
|
|
143
125
|
- Create a new UI Test target in your Xcode project ([top part of this article](https://krausefx.com/blog/run-xcode-7-ui-tests-from-the-command-line))
|
@@ -168,7 +150,9 @@ XCUIApplication *app = [[XCUIApplication alloc] init];
|
|
168
150
|
|
169
151
|
![assets/snapshot.gif](assets/snapshot.gif)
|
170
152
|
|
171
|
-
You can
|
153
|
+
You can try the `snapshot` [example project](https://github.com/fastlane/fastlane/tree/master/snapshot/example) by cloning this repo.
|
154
|
+
|
155
|
+
To quick start your UI tests, you can use the UI Test recorder. You only have to interact with the simulator, and Xcode will generate the UI Test code for you. You can find the red record button on the bottom of the screen (more information in [this blog post](https://krausefx.com/blog/run-xcode-7-ui-tests-from-the-command-line))
|
172
156
|
|
173
157
|
# Usage
|
174
158
|
|
@@ -325,9 +309,9 @@ The easiest solution would be to just render the UIWindow into a file. That's no
|
|
325
309
|
|
326
310
|
When you run unit tests in Xcode, the reporter generates a plist file, documenting all events that occurred during the tests ([More Information](http://michele.io/test-logs-in-xcode)). Additionally, Xcode generates screenshots before, during and after each of these events. There is no way to manually trigger a screenshot event. The screenshots and the plist files are stored in the DerivedData directory, which `snapshot` stores in a temporary folder.
|
327
311
|
|
328
|
-
When the user calls `snapshot(...)` in the UI Tests (Swift or Objective C) the script actually does a rotation to `.Unknown` which doesn't have any effect on the actual app, but is enough to trigger a screenshot. It has no effect to the application and is not something you would do in your tests. The goal was to find *some* event that a user would never trigger, so that we know it's from `snapshot`.
|
312
|
+
When the user calls `snapshot(...)` in the UI Tests (Swift or Objective C) the script actually does a rotation to `.Unknown` which doesn't have any effect on the actual app, but is enough to trigger a screenshot. It has no effect to the application and is not something you would do in your tests. The goal was to find *some* event that a user would never trigger, so that we know it's from `snapshot`. On tvOS, there is no orientation so we ask for a count of app views with type "Browser" (which should never exist on tvOS).
|
329
313
|
|
330
|
-
`snapshot` then iterates through all test events and check where we did this weird rotation. Once `snapshot` has all events triggered by `snapshot` it collects a ordered list of all the file names of the actual screenshots of the application.
|
314
|
+
`snapshot` then iterates through all test events and check where we either did this weird rotation (on iOS) or searched for browsers (on tvOS). Once `snapshot` has all events triggered by `snapshot` it collects a ordered list of all the file names of the actual screenshots of the application.
|
331
315
|
|
332
316
|
In the test output, the Swift `snapshot` function will print out something like this
|
333
317
|
|
@@ -94,13 +94,22 @@ public class Snapshot: NSObject {
|
|
94
94
|
waitForLoadingIndicatorToDisappear()
|
95
95
|
}
|
96
96
|
|
97
|
-
print("snapshot: \(name)") // more information about this, check out https://github.com/fastlane/fastlane/tree/master/snapshot
|
97
|
+
print("snapshot: \(name)") // more information about this, check out https://github.com/fastlane/fastlane/tree/master/snapshot#how-does-it-work
|
98
98
|
|
99
99
|
sleep(1) // Waiting for the animation to be finished (kind of)
|
100
|
-
|
100
|
+
|
101
|
+
#if os(tvOS)
|
102
|
+
XCUIApplication().childrenMatchingType(.Browser).count
|
103
|
+
#else
|
104
|
+
XCUIDevice.sharedDevice().orientation = .Unknown
|
105
|
+
#endif
|
101
106
|
}
|
102
107
|
|
103
108
|
class func waitForLoadingIndicatorToDisappear() {
|
109
|
+
#if os(tvOS)
|
110
|
+
return;
|
111
|
+
#endif
|
112
|
+
|
104
113
|
let query = XCUIApplication().statusBars.childrenMatchingType(.Other).elementBoundByIndex(1).childrenMatchingType(.Other)
|
105
114
|
|
106
115
|
while (0..<query.count).map({ query.elementBoundByIndex($0) }).contains({ $0.isLoadingIndicator }) {
|
data/lib/snapshot.rb
CHANGED
@@ -5,7 +5,7 @@ require 'snapshot/detect_values'
|
|
5
5
|
require 'snapshot/screenshot_flatten'
|
6
6
|
require 'snapshot/screenshot_rotate'
|
7
7
|
require 'snapshot/dependency_checker'
|
8
|
-
require 'snapshot/
|
8
|
+
require 'snapshot/latest_os_version'
|
9
9
|
require 'snapshot/test_command_generator'
|
10
10
|
require 'snapshot/error_handler'
|
11
11
|
require 'snapshot/collector'
|
@@ -45,6 +45,7 @@ module Snapshot
|
|
45
45
|
|
46
46
|
Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
|
47
47
|
UI = FastlaneCore::UI
|
48
|
+
ROOT = Pathname.new(File.expand_path('../..', __FILE__))
|
48
49
|
|
49
50
|
Snapshot::DependencyChecker.check_dependencies
|
50
51
|
|
data/lib/snapshot/collector.rb
CHANGED
@@ -73,8 +73,11 @@ module Snapshot
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def self.check_activity(activity, to_store)
|
76
|
-
#
|
77
|
-
|
76
|
+
# On iOS, we look for the "Unknown" rotation gesture that signals a snapshot was taken here.
|
77
|
+
# On tvOS, we look for "Browser" count.
|
78
|
+
# These are both events that are not normally triggered by UI testing, making it easy for us to
|
79
|
+
# locate where snapshot() was invoked.
|
80
|
+
if activity["Title"] == "Set device orientation to Unknown" || activity["Title"] == "Get number of matches for: Children matching type Browser"
|
78
81
|
if activity["Attachments"]
|
79
82
|
to_store << activity["Attachments"].last["FileName"]
|
80
83
|
else # Xcode 7.3 has stopped including 'Attachments', so we synthesize the filename manually
|
@@ -13,7 +13,6 @@ module Snapshot
|
|
13
13
|
FastlaneCore::UpdateChecker.show_update_status('snapshot', Snapshot::VERSION)
|
14
14
|
end
|
15
15
|
|
16
|
-
# rubocop:disable Metrics/MethodLength
|
17
16
|
def run
|
18
17
|
program :version, Snapshot::VERSION
|
19
18
|
program :description, 'CLI for \'snapshot\' - Automate taking localized screenshots of your iOS app on every device'
|
@@ -67,7 +66,7 @@ module Snapshot
|
|
67
66
|
c.option '-i', '--ios String', String, 'The comma separated list of iOS Versions you want to use'
|
68
67
|
|
69
68
|
c.action do |args, options|
|
70
|
-
options.default ios_version: Snapshot::
|
69
|
+
options.default ios_version: Snapshot::LatestOsVersion.ios_version
|
71
70
|
versions = options.ios_version.split(',') if options.ios_version
|
72
71
|
require 'snapshot/reset_simulators'
|
73
72
|
|
@@ -17,7 +17,7 @@ module Snapshot
|
|
17
17
|
UI.user_error!("Run 'xcode-select --install' and start snapshot again")
|
18
18
|
end
|
19
19
|
|
20
|
-
if Snapshot::
|
20
|
+
if Snapshot::LatestOsVersion.ios_version.to_f < 9 # to_f is bad, but should be good enough
|
21
21
|
UI.error '#############################################################'
|
22
22
|
UI.error "# Your xcode-select Xcode version is below 7.0"
|
23
23
|
UI.error "# To use snapshot 1.0 and above you need at least iOS 9"
|
@@ -23,10 +23,25 @@ module Snapshot
|
|
23
23
|
config[:devices] = []
|
24
24
|
|
25
25
|
# We only care about a subset of the simulators
|
26
|
-
FastlaneCore::Simulator.all
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
all_simulators = FastlaneCore::Simulator.all
|
27
|
+
all_simulators.each do |sim|
|
28
|
+
# Filter iPads, we only want the following simulators
|
29
|
+
# Xcode 7:
|
30
|
+
# ["iPad Pro", "iPad Air"]
|
31
|
+
# Xcode 8:
|
32
|
+
# ["iPad Pro (9.7 Inch)", "iPad Pro (12.9 Inch)"]
|
33
|
+
#
|
34
|
+
# Full list: ["iPad 2", "iPad Retina", "iPad Air", "iPad Air 2", "iPad Pro"]
|
35
|
+
next if sim.name.include?("iPad 2")
|
36
|
+
next if sim.name.include?("iPad Retina")
|
37
|
+
next if sim.name.include?("iPad Air 2")
|
38
|
+
# In Xcode 8, we only need iPad Pro 9.7 inch, not the iPad Air
|
39
|
+
next if all_simulators.any? { |a| a.name.include?("9.7 inch") } && sim.name.include?("iPad Air")
|
40
|
+
|
41
|
+
# Filter iPhones
|
42
|
+
# Full list: ["iPhone 4s", "iPhone 5", "iPhone 5s", "iPhone 6", "iPhone 6 Plus", "iPhone 6s", "iPhone 6s Plus"]
|
43
|
+
next if sim.name.include?("6s") # same screen resolution as iPhone 6, or iPhone 6s Plus
|
44
|
+
next if sim.name.include?("5s") # same screen resolution as iPhone 5
|
30
45
|
next if sim.name.include?("Apple TV")
|
31
46
|
|
32
47
|
config[:devices] << sim.name
|
@@ -9,7 +9,7 @@ module Snapshot
|
|
9
9
|
def self.patch
|
10
10
|
UI.message "Patching '#{config_path}' to scale simulator to 100%"
|
11
11
|
|
12
|
-
FastlaneCore::
|
12
|
+
FastlaneCore::DeviceManager.simulators.each do |simulator|
|
13
13
|
simulator_name = simulator.name.tr("\s", "-")
|
14
14
|
key = "SimulatorWindowLastScale-com.apple.CoreSimulator.SimDeviceType.#{simulator_name}"
|
15
15
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Snapshot
|
2
|
+
class LatestOsVersion
|
3
|
+
def self.ios_version
|
4
|
+
return ENV["SNAPSHOT_IOS_VERSION"] if ENV["SNAPSHOT_IOS_VERSION"]
|
5
|
+
self.version("iOS")
|
6
|
+
end
|
7
|
+
|
8
|
+
@versions = {}
|
9
|
+
def self.version(os)
|
10
|
+
@versions[os] ||= version_for_os(os)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.version_for_os(os)
|
14
|
+
# We do all this, because we would get all kind of crap output generated by xcodebuild
|
15
|
+
# so we need to ignore stderror
|
16
|
+
output = ''
|
17
|
+
Open3.popen3('xcodebuild -version -sdk') do |stdin, stdout, stderr, wait_thr|
|
18
|
+
output = stdout.read
|
19
|
+
end
|
20
|
+
|
21
|
+
matched = output.match(/#{os} ([\d\.]+) \(.*/)
|
22
|
+
if matched.nil?
|
23
|
+
UI.user_error!("Could not determine installed #{os} SDK version. Try running the _xcodebuild_ command manually to ensure it works.")
|
24
|
+
elsif matched.length > 1
|
25
|
+
return matched[1]
|
26
|
+
else
|
27
|
+
UI.user_error!("Could not determine installed #{os} SDK version. Please pass it via the environment variable 'SNAPSHOT_IOS_VERSION'")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/snapshot/options.rb
CHANGED
@@ -35,7 +35,7 @@ module Snapshot
|
|
35
35
|
type: Array,
|
36
36
|
optional: true,
|
37
37
|
verify_block: proc do |value|
|
38
|
-
available = FastlaneCore::
|
38
|
+
available = FastlaneCore::DeviceManager.simulators
|
39
39
|
value.each do |current|
|
40
40
|
unless available.any? { |d| d.name.strip == current.strip }
|
41
41
|
UI.user_error!("Device '#{current}' not in list of available simulators '#{available.join(', ')}'")
|
@@ -61,7 +61,7 @@ module Snapshot
|
|
61
61
|
FastlaneCore::ConfigItem.new(key: :ios_version,
|
62
62
|
description: "By default, the latest version should be used automatically. If you want to change it, do it here",
|
63
63
|
short_option: "-i",
|
64
|
-
|
64
|
+
optional: true),
|
65
65
|
FastlaneCore::ConfigItem.new(key: :skip_open_summary,
|
66
66
|
env_name: 'SNAPSHOT_SKIP_OPEN_SUMMARY',
|
67
67
|
description: "Don't open the HTML summary after running `snapshot`",
|
@@ -111,7 +111,7 @@ module Snapshot
|
|
111
111
|
short_option: "-l",
|
112
112
|
env_name: "SNAPSHOT_BUILDLOG_PATH",
|
113
113
|
description: "The directory where to store the build log",
|
114
|
-
default_value: "
|
114
|
+
default_value: "#{FastlaneCore::Helper.buildlog_path}/snapshot"),
|
115
115
|
FastlaneCore::ConfigItem.new(key: :clean,
|
116
116
|
short_option: "-c",
|
117
117
|
env_name: "SNAPSHOT_CLEAN",
|
data/lib/snapshot/page.html.erb
CHANGED
@@ -147,7 +147,7 @@
|
|
147
147
|
imageDisplay.dataset.counter = img.dataset.counter;
|
148
148
|
|
149
149
|
imageInfo.innerHTML = '<h3>'+img.alt+'</h3>';
|
150
|
-
imageInfo.innerHTML += img.src.split("/").pop();
|
150
|
+
imageInfo.innerHTML += decodeURI(img.src.split("/").pop());
|
151
151
|
imageInfo.innerHTML += '<br />'+tmpImg.height+'×'+tmpImg.width+'px';
|
152
152
|
|
153
153
|
overlay.style.display = "block";
|
@@ -52,12 +52,13 @@ module Snapshot
|
|
52
52
|
# The order IS important, since those names are used to check for include?
|
53
53
|
# and the iPhone 6 is inlucded in the iPhone 6 Plus
|
54
54
|
{
|
55
|
-
'
|
56
|
-
'
|
57
|
-
'
|
58
|
-
'
|
59
|
-
'
|
60
|
-
'
|
55
|
+
'AppleTV1080p' => 'Apple TV',
|
56
|
+
'iPhone6sPlus' => "iPhone6sPlus (5.5-Inch)",
|
57
|
+
'iPhone6Plus' => "iPhone6Plus (5.5-Inch)",
|
58
|
+
'iPhone6s' => "iPhone6s (4.7-Inch)",
|
59
|
+
'iPhone6' => "iPhone6 (4.7-Inch)",
|
60
|
+
'iPhone5' => "iPhone5 (4-Inch)",
|
61
|
+
'iPhone4' => "iPhone4 (3.5-Inch)",
|
61
62
|
'iPadPro' => "iPad Pro",
|
62
63
|
'iPad' => "iPad",
|
63
64
|
'Mac' => "Mac"
|
data/lib/snapshot/runner.rb
CHANGED
@@ -9,7 +9,6 @@ module Snapshot
|
|
9
9
|
# All the errors we experience while running snapshot
|
10
10
|
attr_accessor :collected_errors
|
11
11
|
|
12
|
-
# rubocop:disable Metrics/AbcSize
|
13
12
|
def work
|
14
13
|
if File.exist?("./fastlane/snapshot.js") or File.exist?("./snapshot.js")
|
15
14
|
UI.error "Found old snapshot configuration file 'snapshot.js'"
|
@@ -64,7 +63,6 @@ module Snapshot
|
|
64
63
|
FileUtils.rm_rf(TestCommandGenerator.derived_data_path)
|
65
64
|
end
|
66
65
|
end
|
67
|
-
# rubocop:enable Metrics/AbcSize
|
68
66
|
|
69
67
|
# This is its own method so that it can re-try if the tests fail randomly
|
70
68
|
# @return true/false depending on if the tests succeded
|
@@ -117,7 +115,6 @@ module Snapshot
|
|
117
115
|
end
|
118
116
|
|
119
117
|
# Returns true if it succeded
|
120
|
-
# rubocop:disable Metrics/AbcSize
|
121
118
|
def launch(language, locale, device_type, launch_arguments)
|
122
119
|
screenshots_path = TestCommandGenerator.derived_data_path
|
123
120
|
FileUtils.rm_rf(File.join(screenshots_path, "Logs"))
|
@@ -196,7 +193,6 @@ module Snapshot
|
|
196
193
|
|
197
194
|
return Collector.fetch_screenshots(raw_output, dir_name, device_type, launch_arguments.first)
|
198
195
|
end
|
199
|
-
# rubocop:enable Metrics/AbcSize
|
200
196
|
|
201
197
|
def open_simulator_for_device(device_name)
|
202
198
|
return unless ENV['FASTLANE_EXPLICIT_OPEN_SIMULATOR']
|
data/lib/snapshot/setup.rb
CHANGED
@@ -8,9 +8,8 @@ module Snapshot
|
|
8
8
|
UI.user_error!("Snapfile already exists at path '#{snapfile_path}'. Run 'snapshot' to use snapshot.")
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
File.write(
|
13
|
-
File.write(File.join(path, 'SnapshotHelper.swift'), File.read("#{gem_path}/lib/assets/SnapshotHelper.swift"))
|
11
|
+
File.write(snapfile_path, File.read("#{Snapshot::ROOT}/lib/assets/SnapfileTemplate"))
|
12
|
+
File.write(File.join(path, 'SnapshotHelper.swift'), File.read("#{Snapshot::ROOT}/lib/assets/SnapshotHelper.swift"))
|
14
13
|
|
15
14
|
puts "Successfully created SnapshotHelper.swift '#{File.join(path, 'SnapshotHelper.swift')}'".green
|
16
15
|
puts "Successfully created new Snapfile at '#{snapfile_path}'".green
|
@@ -64,7 +64,7 @@ module Snapshot
|
|
64
64
|
["| tee #{xcodebuild_log_path.shellescape} | xcpretty #{Snapshot.config[:xcpretty_args]}"]
|
65
65
|
end
|
66
66
|
|
67
|
-
def find_device(device_name)
|
67
|
+
def find_device(device_name, os_version)
|
68
68
|
# We might get this error message
|
69
69
|
# > The requested device could not be found because multiple devices matched the request.
|
70
70
|
#
|
@@ -72,19 +72,28 @@ module Snapshot
|
|
72
72
|
# { platform:iOS Simulator, id:1685B071-AFB2-4DC1-BE29-8370BA4A6EBD, OS:9.0, name:iPhone 5 }
|
73
73
|
# { platform:iOS Simulator, id:A141F23B-96B3-491A-8949-813B376C28A7, OS:9.0, name:iPhone 5 }
|
74
74
|
#
|
75
|
-
|
76
|
-
|
75
|
+
|
76
|
+
FastlaneCore::DeviceManager.simulators.find do |sim|
|
77
|
+
sim.name.strip == device_name.strip and sim.os_version == os_version
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
80
|
-
def device_udid(device_name)
|
81
|
-
device = find_device(device_name)
|
81
|
+
def device_udid(device_name, os_version = Snapshot.config[:ios_version])
|
82
|
+
device = find_device(device_name, os_version)
|
82
83
|
|
83
84
|
device ? device.udid : nil
|
84
85
|
end
|
85
86
|
|
86
|
-
def destination(
|
87
|
-
|
87
|
+
def destination(device_name)
|
88
|
+
os = device_name =~ /^Apple TV/ ? "tvOS" : "iOS"
|
89
|
+
os_version = Snapshot.config[:ios_version] || Snapshot::LatestOsVersion.version(os)
|
90
|
+
|
91
|
+
device = find_device(device_name, os_version)
|
92
|
+
if device.nil?
|
93
|
+
UI.user_error!("No device found named '#{device_name}' for version '#{os_version}'")
|
94
|
+
return
|
95
|
+
end
|
96
|
+
value = "platform=#{os} Simulator,id=#{device.udid},OS=#{os_version}"
|
88
97
|
|
89
98
|
return ["-destination '#{value}'"]
|
90
99
|
end
|
data/lib/snapshot/update.rb
CHANGED
@@ -7,7 +7,6 @@ module Snapshot
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def update
|
10
|
-
gem_path = Helper.gem_path("snapshot")
|
11
10
|
paths = self.class.find_helper
|
12
11
|
|
13
12
|
UI.message "Found the following SnapshotHelper:"
|
@@ -15,13 +14,13 @@ module Snapshot
|
|
15
14
|
UI.important "Are you sure you want to automatically update the helpers listed above?"
|
16
15
|
UI.message "This will overwrite all its content with the latest code."
|
17
16
|
UI.message "The underlying API will not change. You can always migrate manually by looking at"
|
18
|
-
UI.message "https://github.com/fastlane/
|
17
|
+
UI.message "https://github.com/fastlane/fastlane/blob/master/snapshot/lib/assets/SnapshotHelper.swift"
|
19
18
|
|
20
19
|
return 1 unless UI.confirm("Overwrite configuration files?")
|
21
20
|
|
22
21
|
paths.each do |path|
|
23
22
|
UI.message "Updating '#{path}'..."
|
24
|
-
File.write(path, File.read("#{
|
23
|
+
File.write(path, File.read("#{Snapshot::ROOT}/lib/assets/SnapshotHelper.swift"))
|
25
24
|
end
|
26
25
|
|
27
26
|
UI.success "Successfully updated helper files"
|
data/lib/snapshot/version.rb
CHANGED
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.
|
4
|
+
version: 1.14.0
|
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-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastimage
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.50.
|
33
|
+
version: 0.50.3
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: 1.0.0
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.50.
|
43
|
+
version: 0.50.3
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 1.0.0
|
@@ -234,7 +234,7 @@ files:
|
|
234
234
|
- lib/snapshot/fixes/README.md
|
235
235
|
- lib/snapshot/fixes/hardware_keyboard_fix.rb
|
236
236
|
- lib/snapshot/fixes/simulator_zoom_fix.rb
|
237
|
-
- lib/snapshot/
|
237
|
+
- lib/snapshot/latest_os_version.rb
|
238
238
|
- lib/snapshot/options.rb
|
239
239
|
- lib/snapshot/page.html.erb
|
240
240
|
- lib/snapshot/reports_generator.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Snapshot
|
2
|
-
class LatestIosVersion
|
3
|
-
@version = nil
|
4
|
-
def self.version
|
5
|
-
return ENV["SNAPSHOT_IOS_VERSION"] if ENV["SNAPSHOT_IOS_VERSION"]
|
6
|
-
return @version if @version
|
7
|
-
|
8
|
-
# We do all this, because we would get all kind of crap output generated by xcodebuild
|
9
|
-
# so we need to ignore stderror
|
10
|
-
output = ''
|
11
|
-
Open3.popen3('xcodebuild -version -sdk') do |stdin, stdout, stderr, wait_thr|
|
12
|
-
output = stdout.read
|
13
|
-
end
|
14
|
-
|
15
|
-
matched = output.match(/iOS ([\d\.]+) \(.*/)
|
16
|
-
if matched.nil?
|
17
|
-
UI.user_error!("Could not determine installed iOS SDK version. Try running the _xcodebuild_ command manually to ensure it works.")
|
18
|
-
elsif matched.length > 1
|
19
|
-
return @version ||= matched[1]
|
20
|
-
else
|
21
|
-
UI.user_error!("Could not determine installed iOS SDK version. Please pass it via the environment variable 'SNAPSHOT_IOS_VERSION'")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|