snapshot 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -11
- data/lib/assets/SnapfileTemplate +1 -1
- data/lib/snapshot/latest_ios_version.rb +3 -1
- data/lib/snapshot/reset_simulators.rb +25 -25
- data/lib/snapshot/runner.rb +10 -4
- data/lib/snapshot/screenshot_flatten.rb +1 -2
- data/lib/snapshot/screenshot_rotate.rb +1 -1
- data/lib/snapshot/simulators.rb +33 -7
- data/lib/snapshot/snapshot_config.rb +18 -8
- data/lib/snapshot/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 524dab0c4b7be609151cb4e277fa150257cfa9b0
|
4
|
+
data.tar.gz: 5eae566a40f1a11789385d14fb49d3439dd06acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99fcceb0567036b19e04c0c20b1348f1595ffd62094b0c57371e11581f16b31042b97f7554edc41042d5e92f9a0e13c0ae80016f73afa31b9ccc680e12873d82
|
7
|
+
data.tar.gz: 0e3ba863d08edea6ca0ebbb46d742bbfcdfbb5ffaf925abf7c3b81e98ed4cc3d02fafae33c56023eeb26e013e4eca5c3f2641c07ecea2877e54a43f2e5488b2e
|
data/README.md
CHANGED
@@ -16,7 +16,8 @@
|
|
16
16
|
<a href="https://github.com/KrauseFx/codes">codes</a> •
|
17
17
|
<a href="https://github.com/fastlane/spaceship">spaceship</a> •
|
18
18
|
<a href="https://github.com/fastlane/pilot">pilot</a> •
|
19
|
-
<a href="https://github.com/fastlane/boarding">boarding</a>
|
19
|
+
<a href="https://github.com/fastlane/boarding">boarding</a> •
|
20
|
+
<a href="https://github.com/fastlane/gym">gym</a>
|
20
21
|
</p>
|
21
22
|
-------
|
22
23
|
|
@@ -376,6 +377,7 @@ You can use the environment variable `SNAPSHOT_FORCE_DELETE` to stop asking for
|
|
376
377
|
- [`spaceship`](https://github.com/fastlane/spaceship): Ruby library to access the Apple Dev Center and iTunes Connect
|
377
378
|
- [`pilot`](https://github.com/fastlane/pilot): The best way to manage your TestFlight testers and builds from your terminal
|
378
379
|
- [`boarding`](https://github.com/fastlane/boarding): The easiest way to invite your TestFlight beta testers
|
380
|
+
- [`gym`](https://github.com/fastlane/gym): Building your iOS apps has never been easier
|
379
381
|
|
380
382
|
##### [Like this tool? Be the first to know about updates and new fastlane tools](https://tinyletter.com/krausefx)
|
381
383
|
|
@@ -477,7 +479,7 @@ Be aware: The file will be executed from the current directory, not the location
|
|
477
479
|
|
478
480
|
## Available language codes
|
479
481
|
```ruby
|
480
|
-
["
|
482
|
+
ALL_LANGUAGES = ["da", "de-DE", "el", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi", "fr-CA", "fr-FR", "id", "it", "ja", "ko", "ms", "nl", "no", "pt-BR", "pt-PT", "ru", "sv", "th", "tr", "vi", "zh-Hans", "zh-Hant"]
|
481
483
|
```
|
482
484
|
|
483
485
|
## Use a clean status bar
|
@@ -546,12 +548,3 @@ var language = result.stdout.substring(0, result.stdout.length - 1);
|
|
546
548
|
This project is licensed under the terms of the MIT license. See the LICENSE file.
|
547
549
|
|
548
550
|
> This project and all fastlane tools are in no way affiliated with Apple Inc. This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs. All fastlane tools run on your own computer or server, so your credentials or other sensitive information will never leave your own computer. You are responsible for how you use fastlane tools.
|
549
|
-
|
550
|
-
# Contributing
|
551
|
-
|
552
|
-
1. Create an issue to discuss about your idea
|
553
|
-
2. Fork it (https://github.com/KrauseFx/snapshot/fork)
|
554
|
-
3. Create your feature branch (`git checkout -b my-new-feature`)
|
555
|
-
4. Commit your changes (`git commit -am 'Add some feature'`)
|
556
|
-
5. Push to the branch (`git push origin my-new-feature`)
|
557
|
-
6. Create a new Pull Request
|
data/lib/assets/SnapfileTemplate
CHANGED
@@ -34,7 +34,7 @@ screenshots_path "./screenshots"
|
|
34
34
|
|
35
35
|
# Comment out the line below to add a `SNAPSHOT` preprocessor macro
|
36
36
|
# More information available: https://github.com/krausefx/snapshot#custom-args-for-the-build-command
|
37
|
-
# custom_build_args "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SNAPSHOT=1'"
|
37
|
+
# custom_build_args "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SNAPSHOT=1' OTHER_SWIFT_FLAGS='$(inherited) -DSNAPSHOT=1'"
|
38
38
|
|
39
39
|
|
40
40
|
# Custom Callbacks
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Snapshot
|
2
2
|
class LatestIosVersion
|
3
|
+
@version = nil
|
3
4
|
def self.version
|
4
5
|
return ENV["SNAPSHOT_IOS_VERSION"] if ENV["SNAPSHOT_IOS_VERSION"]
|
6
|
+
return @version if @version
|
5
7
|
|
6
8
|
output = `xcodebuild -version -sdk`.split("Mac").last # don't care about the Mac Part
|
7
9
|
matched = output.match(/iPhoneSimulator([\d\.]+)\.sdk/)
|
8
10
|
|
9
11
|
if matched.length > 1
|
10
|
-
return matched[1]
|
12
|
+
return @version ||= matched[1]
|
11
13
|
else
|
12
14
|
raise "Could not determine installed iOS SDK version. Please pass it via the environment variable 'SNAPSHOT_IOS_VERSION'".red
|
13
15
|
end
|
@@ -1,42 +1,42 @@
|
|
1
1
|
module Snapshot
|
2
2
|
class ResetSimulators
|
3
3
|
def self.clear_everything!(ios_version)
|
4
|
-
# Taken from https://gist.github.com/cabeca/cbaacbeb6a1cc4683aa5
|
5
|
-
|
6
4
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
7
5
|
# !! Warning: This script will remove all your existing simulators !!
|
8
6
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
9
7
|
|
10
8
|
sure = true if ENV["SNAPSHOT_FORCE_DELETE"]
|
11
9
|
sure = agree("Are you sure? All your simulators will be DELETED and new ones will be created! (y/n)".red, true) unless sure
|
12
|
-
|
13
10
|
raise "User cancelled action" unless sure
|
14
|
-
|
15
|
-
device_types_output = `xcrun simctl list devicetypes`
|
16
|
-
device_types = device_types_output.scan /(.*) \((.*)\)/
|
17
|
-
|
18
|
-
devices_output = `xcrun simctl list devices`.split("\n")
|
19
11
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
12
|
+
all_devices = `xcrun simctl list devices`
|
13
|
+
# == Devices ==
|
14
|
+
# -- iOS 9.0 --
|
15
|
+
# iPhone 4s (32246EBC-33B0-47F9-B7BB-5C23C550DF29) (Shutdown)
|
16
|
+
# iPhone 5 (4B56C101-6B95-43D1-9485-3FBA0E127FFA) (Shutdown)
|
17
|
+
# iPhone 5s (6379C204-E82A-4FBD-8A22-6A01C7791D62) (Shutdown)
|
18
|
+
# -- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-8-4 --
|
19
|
+
# iPhone 4s (FE9D6F85-1C51-4FE6-8597-FCAB5286B869) (Shutdown) (unavailable, runtime profile not found)
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
21
|
+
all_devices.split("\n").each do |line|
|
22
|
+
parsed = line.match(/\s+([\w\s]+)\s\(([\w\-]+)\)/) || []
|
23
|
+
next unless parsed.length == 3 # we don't care about those headers
|
24
|
+
parsed, name, id = parsed.to_a
|
25
|
+
puts "Removing device #{name} (#{id})"
|
26
|
+
`xcrun simctl delete #{id}`
|
27
|
+
end
|
28
|
+
|
29
|
+
all_device_types = `xcrun simctl list devicetypes`.scan(/(.*)\s\((.*)\)/)
|
30
|
+
# == Device Types ==
|
31
|
+
# iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
|
32
|
+
# iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
|
33
|
+
# iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
|
34
|
+
# iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
|
35
|
+
all_device_types.each do |device_type|
|
36
|
+
next if device_type.join(' ').include?"Watch" # we don't want to deal with the Watch right now
|
36
37
|
|
37
38
|
puts "Creating #{device_type} for iOS version #{ios_version}"
|
38
|
-
|
39
|
-
command_output = `#{command}`
|
39
|
+
`xcrun simctl create '#{device_type[0]}' #{device_type[1]} #{ios_version}`
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/snapshot/runner.rb
CHANGED
@@ -85,7 +85,7 @@ module Snapshot
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def udid_for_simulator(name) # fetches the UDID of the simulator type
|
88
|
-
all =
|
88
|
+
all = Simulators.raw_simulators.split("\n")
|
89
89
|
all.each do |current|
|
90
90
|
return current.match(/\[(.*)\]/)[1] if current.include?name
|
91
91
|
end
|
@@ -100,13 +100,14 @@ module Snapshot
|
|
100
100
|
|
101
101
|
def com(cmd)
|
102
102
|
puts cmd.magenta if $verbose
|
103
|
-
|
104
|
-
|
103
|
+
Open3.popen3("#{cmd} 2>&1") do |stdin, stdout, stderr, wait_thr|
|
104
|
+
result = stdout.read
|
105
|
+
puts result if (result.to_s.length > 0 and $verbose)
|
106
|
+
end
|
105
107
|
end
|
106
108
|
|
107
109
|
udid = udid_for_simulator(device)
|
108
110
|
|
109
|
-
|
110
111
|
com("killall 'iOS Simulator'")
|
111
112
|
sleep 3
|
112
113
|
com("xcrun simctl boot '#{udid}'")
|
@@ -198,6 +199,11 @@ module Snapshot
|
|
198
199
|
def parse_test_line(line)
|
199
200
|
if line =~ /.*Target failed to run.*/
|
200
201
|
return :retry
|
202
|
+
elsif line.include?"segmentation fault" # a new bug introduced with Xcode 7
|
203
|
+
return :retry
|
204
|
+
elsif line.include?"Timed out waiting" # a new bug introduced with Xcode 7
|
205
|
+
`killall "iOS Simulator"`
|
206
|
+
return :retry
|
201
207
|
elsif line.include?"Screenshot captured"
|
202
208
|
return :screenshot
|
203
209
|
elsif line.include? "Instruments wants permission to analyze other processes"
|
@@ -3,7 +3,7 @@ module Snapshot
|
|
3
3
|
class ScreenshotFlatten
|
4
4
|
# @param (String) The path in which the screenshots are located in
|
5
5
|
def run(path)
|
6
|
-
Helper.log.info "
|
6
|
+
Helper.log.info "Removing the alpha channel from generated png files"
|
7
7
|
flatten(path)
|
8
8
|
end
|
9
9
|
|
@@ -13,7 +13,6 @@ module Snapshot
|
|
13
13
|
`sips -s format bmp '#{file}' &> /dev/null ` # &> /dev/null because there is warning because of the extension
|
14
14
|
`sips -s format png '#{file}'`
|
15
15
|
end
|
16
|
-
Helper.log.info "Finished removing the alpha channel."
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -5,7 +5,7 @@ module Snapshot
|
|
5
5
|
class ScreenshotRotate
|
6
6
|
# @param (String) The path in which the screenshots are located in
|
7
7
|
def run(path)
|
8
|
-
Helper.log.debug "
|
8
|
+
Helper.log.debug "Rotating the screenshots (if necessary)"
|
9
9
|
rotate(path)
|
10
10
|
end
|
11
11
|
|
data/lib/snapshot/simulators.rb
CHANGED
@@ -1,14 +1,40 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
1
3
|
module Snapshot
|
2
4
|
class Simulators
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
# @return the raw value of the `instruments -s` command
|
6
|
+
# we do it using `open3` since only ` just randomly hangs with instruments -s
|
7
|
+
def self.raw_simulators
|
8
|
+
return @result if @result
|
9
|
+
|
10
|
+
Open3.popen3('instruments -s') do |stdin, stdout, stderr, wait_thr|
|
11
|
+
@result = stdout.read
|
12
|
+
end
|
13
|
+
|
14
|
+
@result || ''
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.available_devices(name_only = false)
|
18
|
+
Helper.log.info "Fetching available devices" if $verbose
|
19
|
+
result = []
|
20
|
+
|
21
|
+
output = self.raw_simulators
|
22
|
+
|
23
|
+
output.split("\n").each do |current|
|
24
|
+
# Example: "iPhone 5 (8.1 Simulator) [C49ECC4A-5A3D-44B6-B9BF-4E25BC326400]"
|
25
|
+
# Example: "iPhone 6 (9.0) [072E4EA2-861F-44CD-AB77-FB1FE07E541C]"
|
26
|
+
|
27
|
+
match = current.match /((.+?) \(.+?\)) \[.+?\]/
|
28
|
+
next if match.nil?
|
29
|
+
|
30
|
+
if name_only
|
31
|
+
result << match[2]
|
32
|
+
else
|
33
|
+
result << match[1]
|
9
34
|
end
|
10
35
|
end
|
11
|
-
|
36
|
+
|
37
|
+
return result
|
12
38
|
end
|
13
39
|
end
|
14
40
|
end
|
@@ -115,10 +115,10 @@ module Snapshot
|
|
115
115
|
# This has to be done after parsing the Snapfile (iOS version)
|
116
116
|
def set_default_simulators
|
117
117
|
self.devices ||= [
|
118
|
-
"iPhone 6 (
|
119
|
-
"iPhone 6 Plus (
|
120
|
-
"iPhone 5 (
|
121
|
-
"iPhone 4s (
|
118
|
+
"iPhone 6" + version_suffix(self.ios_version),
|
119
|
+
"iPhone 6 Plus" + version_suffix(self.ios_version),
|
120
|
+
"iPhone 5" + version_suffix(self.ios_version),
|
121
|
+
"iPhone 4s" + version_suffix(self.ios_version),
|
122
122
|
]
|
123
123
|
end
|
124
124
|
|
@@ -128,12 +128,12 @@ module Snapshot
|
|
128
128
|
|
129
129
|
actual_devices = []
|
130
130
|
self.devices.each do |current|
|
131
|
-
current +=
|
131
|
+
current += version_suffix(self.ios_version) unless current.include? " ("
|
132
132
|
|
133
|
-
|
134
|
-
raise "Device '#{current}' not found. Available device types: #{Simulators.available_devices}".red
|
135
|
-
else
|
133
|
+
if Simulators.available_devices.include? current
|
136
134
|
actual_devices << current
|
135
|
+
else
|
136
|
+
raise "Device '#{current}' not found. Available device types: #{Simulators.available_devices}".red
|
137
137
|
end
|
138
138
|
end
|
139
139
|
self.devices = actual_devices
|
@@ -219,5 +219,15 @@ module Snapshot
|
|
219
219
|
raise "Could not fetch available schemes: #{ex}".red
|
220
220
|
end
|
221
221
|
end
|
222
|
+
|
223
|
+
def version_suffix version
|
224
|
+
# Xcode 6 and before: "iPhone 5 (8.0 Simulator)"
|
225
|
+
# Xcode 7 and later: "iPhone 6 (9.0)"
|
226
|
+
if LatestIosVersion.version.to_i >= 9
|
227
|
+
" (#{version})"
|
228
|
+
else
|
229
|
+
" (#{version} Simulator)"
|
230
|
+
end
|
231
|
+
end
|
222
232
|
end
|
223
233
|
end
|
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: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastimage
|
@@ -30,14 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.16.1
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.0.0
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
43
|
+
version: 0.16.1
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.0.0
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: bundler
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|