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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d48db6f3a941d5415f919c885128617eccbd045b
4
- data.tar.gz: 48accee55c96d5ae5de75688f3076f3e2cc66ca2
3
+ metadata.gz: 524dab0c4b7be609151cb4e277fa150257cfa9b0
4
+ data.tar.gz: 5eae566a40f1a11789385d14fb49d3439dd06acf
5
5
  SHA512:
6
- metadata.gz: 3575a0c9b77f63f603741441ef3d363f1108c4da48d1b2047d6ae6d08494ea4f3febf43e83ef860fd7839b57c2efdfc6a6a144876531cbba48cc680a82874023
7
- data.tar.gz: cd25ef5ec5eb98bb7d708f0ecec4c66bfb91805e0351e62860ccfd0b2cb0d54cc7499b20f69b7d8782258afa6a8ea4e3b9c67f6d7a0ae14f9f8124e659ca5763
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> &bull;
17
17
  <a href="https://github.com/fastlane/spaceship">spaceship</a> &bull;
18
18
  <a href="https://github.com/fastlane/pilot">pilot</a> &bull;
19
- <a href="https://github.com/fastlane/boarding">boarding</a>
19
+ <a href="https://github.com/fastlane/boarding">boarding</a> &bull;
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
- ["cs-CZ", "da-DK", "de-DE", "el-GR", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi-FI", "fr-CA", "fr-FR", "id-ID", "it-IT", "ja-JP", "ko-KR", "ms-MY", "nl-NL", "no-NO", "pt-BR", "pt-PT", "ru-RU", "sv-SE", "th-TH", "tr-TR", "vi-VI", "cmn-Hans", "cmn-Hant"]
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
@@ -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
- devices_output.each do |line|
21
- device = line.match(/\s+([\w\s]+)\(([\w\-]+)\)/)
22
- if device and device.length == 3
23
- name = device[1].strip
24
- id = device[2]
25
- puts "Removing device #{name} (#{id})"
26
- `xcrun simctl delete #{id}`
27
- end
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
- # device_types
31
- # ["iPhone 5", "com.apple.CoreSimulator.SimDeviceType.iPhone-5"],
32
- # ["iPhone 5s", "com.apple.CoreSimulator.SimDeviceType.iPhone-5s"],
33
- # ["iPhone 6", "com.apple.CoreSimulator.SimDeviceType.iPhone-6"],
34
- device_types.each do |device_type|
35
- next if device_type.first.include?"Watch" # we don't want to deal with the Watch right now
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
- command = "xcrun simctl create '#{device_type[0]}' #{device_type[1]} #{ios_version}"
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
@@ -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 = `instruments -s`.split("\n")
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
- result = `#{cmd} 2>&1` # to now show errors
104
- puts result if (result.to_s.length > 0 and $verbose)
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 "Going to remove the alpha channel from generated png files"
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 "Going to rotate screenshots from generated png files"
8
+ Helper.log.debug "Rotating the screenshots (if necessary)"
9
9
  rotate(path)
10
10
  end
11
11
 
@@ -1,14 +1,40 @@
1
+ require 'open3'
2
+
1
3
  module Snapshot
2
4
  class Simulators
3
- def self.available_devices
4
- if not @result
5
- @result = []
6
- `instruments -s`.split("\n").each do |current|
7
- # Example: "iPhone 5 (8.1 Simulator) [C49ECC4A-5A3D-44B6-B9BF-4E25BC326400]"
8
- @result << current.split(' [').first if current.include?"Simulator"
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
- return @result
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 (#{self.ios_version} Simulator)",
119
- "iPhone 6 Plus (#{self.ios_version} Simulator)",
120
- "iPhone 5 (#{self.ios_version} Simulator)",
121
- "iPhone 4s (#{self.ios_version} Simulator)"
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 += " (#{self.ios_version} Simulator)" unless current.include?"Simulator"
131
+ current += version_suffix(self.ios_version) unless current.include? " ("
132
132
 
133
- unless Simulators.available_devices.include?current
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
@@ -1,3 +1,3 @@
1
1
  module Snapshot
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
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.2
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-07-24 00:00:00.000000000 Z
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.7.2
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.7.2
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