snapshot 1.4.1 → 1.4.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: db3ce6c9d6f26b06837afca256da0a7b30a2d27c
4
- data.tar.gz: 7a206b57ce9f47942511be89a86fbaee968aca3c
3
+ metadata.gz: 96f6aa6d5034a51c6bd41f7c1ba31796b19daa55
4
+ data.tar.gz: 2ffaec44d9ca48065f8dada8142b8f324740be5a
5
5
  SHA512:
6
- metadata.gz: 985c1e44237b8afa4abb5553c1820a7b8c5429133771d41683d82caa8013cb3580879f06e4759e7238e5849a6a61a8f1e3df256479af306448b52006d01e73b4
7
- data.tar.gz: b6866944c914b6d4fe80cfd558e6d2cf264cbda799f712f221510d8cd91597c1ba1c3ef65066c5e5ca7ae5a0749595da68c52103a36dc4840cad9eb0b5779a64
6
+ metadata.gz: a06cc5ff23182185afa183e4928fb4b0b041ec4943157e21424cbc69d40b92a8fbce0e7c23d97d5c07d1c37c9c72ac242949892619a71d6527e7552d3f1fa02c
7
+ data.tar.gz: 777220ead255052ff6d08eb231d0efdbefaf8d0dbd8b041bee9b4425128ccf49224279e72ce5db86866f95130f5e3ce4c0f2ec8cb159612a02e812ae7381f7e4
data/README.md CHANGED
@@ -17,7 +17,8 @@
17
17
  <a href="https://github.com/fastlane/pilot">pilot</a> &bull;
18
18
  <a href="https://github.com/fastlane/boarding">boarding</a> &bull;
19
19
  <a href="https://github.com/fastlane/gym">gym</a> &bull;
20
- <a href="https://github.com/fastlane/scan">scan</a>
20
+ <a href="https://github.com/fastlane/scan">scan</a> &bull;
21
+ <a href="https://github.com/fastlane/match">match</a>
21
22
  </p>
22
23
  -------
23
24
 
@@ -333,6 +334,7 @@ Also, feel free to duplicate radar [23062925](https://openradar.appspot.com/rada
333
334
  - [`boarding`](https://github.com/fastlane/boarding): The easiest way to invite your TestFlight beta testers
334
335
  - [`gym`](https://github.com/fastlane/gym): Building your iOS apps has never been easier
335
336
  - [`scan`](https://github.com/fastlane/scan): The easiest way to run tests of your iOS and Mac app
337
+ - [`match`](https://github.com/fastlane/match): Easily sync your certificates and profiles across your team using git
336
338
 
337
339
  ##### [Like this tool? Be the first to know about updates and new fastlane tools](https://tinyletter.com/krausefx)
338
340
 
@@ -17,8 +17,7 @@ func setLanguage(app: XCUIApplication) {
17
17
  }
18
18
 
19
19
  func setupSnapshot(app: XCUIApplication) {
20
- Snapshot.setLanguage(app)
21
- Snapshot.setLaunchArguments(app)
20
+ Snapshot.setupSnapshot(app)
22
21
  }
23
22
 
24
23
  func snapshot(name: String, waitForLoadingIndicator: Bool = false) {
@@ -26,10 +25,15 @@ func snapshot(name: String, waitForLoadingIndicator: Bool = false) {
26
25
  }
27
26
 
28
27
  class Snapshot: NSObject {
29
-
28
+
29
+ class func setupSnapshot(app: XCUIApplication) {
30
+ setLanguage(app)
31
+ setLaunchArguments(app)
32
+ }
33
+
30
34
  class func setLanguage(app: XCUIApplication) {
31
35
  let path = "/tmp/language.txt"
32
-
36
+
33
37
  do {
34
38
  let locale = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
35
39
  deviceLanguage = locale.substringToIndex(locale.startIndex.advancedBy(2, limit:locale.endIndex))
@@ -38,12 +42,12 @@ class Snapshot: NSObject {
38
42
  print("Couldn't detect/set language...")
39
43
  }
40
44
  }
41
-
45
+
42
46
  class func setLaunchArguments(app: XCUIApplication) {
43
47
  let path = "/tmp/snapshot-launch_arguments.txt"
44
-
48
+
45
49
  app.launchArguments += ["-FASTLANE_SNAPSHOT", "YES"]
46
-
50
+
47
51
  do {
48
52
  let launchArguments = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
49
53
  let regex = try NSRegularExpression(pattern: "(\\\".+?\\\"|\\S+)", options: [])
@@ -56,18 +60,18 @@ class Snapshot: NSObject {
56
60
  print("Couldn't detect/set launch_arguments...")
57
61
  }
58
62
  }
59
-
63
+
60
64
  class func snapshot(name: String, waitForLoadingIndicator: Bool = false) {
61
65
  if waitForLoadingIndicator {
62
66
  waitForLoadingIndicatorToDisappear()
63
67
  }
64
-
68
+
65
69
  print("snapshot: \(name)") // more information about this, check out https://github.com/krausefx/snapshot
66
-
70
+
67
71
  sleep(1) // Waiting for the animation to be finished (kind of)
68
72
  XCUIDevice.sharedDevice().orientation = .Unknown
69
73
  }
70
-
74
+
71
75
  class func waitForLoadingIndicatorToDisappear() {
72
76
  let query = XCUIApplication().statusBars.childrenMatchingType(.Other).elementBoundByIndex(1).childrenMatchingType(.Other)
73
77
 
@@ -9,23 +9,16 @@ module Snapshot
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
10
  raise "User cancelled action" unless sure
11
11
 
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)
20
-
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
- _, name, id = parsed.to_a
12
+ devices.each do |device|
13
+ _, name, id = device
25
14
  puts "Removing device #{name} (#{id})"
26
15
  `xcrun simctl delete #{id}`
27
16
  end
28
17
 
18
+ all_runtimes = `xcrun simctl list runtimes`.lines.map { |s| s.slice(/(.*?) \(/, 1) }.compact
19
+ tv_versions = filter_runtimes(all_runtimes, 'tvOS')
20
+ watch_versions = filter_runtimes(all_runtimes, 'watchOS')
21
+
29
22
  all_device_types = `xcrun simctl list devicetypes`.scan(/(.*)\s\((.*)\)/)
30
23
  # == Device Types ==
31
24
  # iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
@@ -33,14 +26,53 @@ module Snapshot
33
26
  # iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
34
27
  # iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
35
28
  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
37
- next if device_type.join(' ').include?("TV") # we don't want to deal with TV right now
38
-
39
- ios_versions.each do |ios_version|
40
- puts "Creating #{device_type} for iOS version #{ios_version}"
41
- `xcrun simctl create '#{device_type[0]}' #{device_type[1]} #{ios_version}`
29
+ if device_type.join(' ').include?("Watch")
30
+ create(device_type, watch_versions, 'watchOS')
31
+ elsif device_type.join(' ').include?("TV")
32
+ create(device_type, tv_versions, 'tvOS')
33
+ else
34
+ create(device_type, ios_versions)
42
35
  end
43
36
  end
37
+
38
+ phones = []
39
+ watches = []
40
+ devices.each do |device|
41
+ _, name, id = device
42
+ phones << id if name.start_with?('iPhone 6')
43
+ watches << id if name.end_with?('mm')
44
+ end
45
+
46
+ puts "Creating device pair of #{phones.last} and #{watches.last}"
47
+ `xcrun simctl pair #{watches.last} #{phones.last}`
48
+ end
49
+
50
+ def self.create(device_type, os_versions, os_name = 'iOS')
51
+ os_versions.each do |os_version|
52
+ puts "Creating #{device_type} for #{os_name} version #{os_version}"
53
+ `xcrun simctl create '#{device_type[0]}' #{device_type[1]} #{os_version}`
54
+ end
55
+ end
56
+
57
+ def self.filter_runtimes(all_runtimes, os = 'iOS')
58
+ all_runtimes.select { |r| r[/^#{os}/] }.map { |r| r.split(' ')[1] }
59
+ end
60
+
61
+ def self.devices
62
+ all_devices = `xcrun simctl list devices`
63
+ # == Devices ==
64
+ # -- iOS 9.0 --
65
+ # iPhone 4s (32246EBC-33B0-47F9-B7BB-5C23C550DF29) (Shutdown)
66
+ # iPhone 5 (4B56C101-6B95-43D1-9485-3FBA0E127FFA) (Shutdown)
67
+ # iPhone 5s (6379C204-E82A-4FBD-8A22-6A01C7791D62) (Shutdown)
68
+ # -- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-8-4 --
69
+ # iPhone 4s (FE9D6F85-1C51-4FE6-8597-FCAB5286B869) (Shutdown) (unavailable, runtime profile not found)
70
+
71
+ result = all_devices.lines.map do |line|
72
+ (line.match(/\s+([\w\s]+)\s\(([\w\-]+)\)/) || []).to_a
73
+ end
74
+
75
+ result.select { |parsed| parsed.length == 3 } # we don't care about those headers
44
76
  end
45
77
  end
46
78
  end
@@ -1,4 +1,4 @@
1
1
  module Snapshot
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  DESCRIPTION = "Automate taking localized screenshots of your iOS app on every device"
4
4
  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: 1.4.1
4
+ version: 1.4.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: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastimage