mmcc007 / screenshots

Screenshots: A command line utility and package for capturing screenshots for Flutter
Other
266 stars 145 forks source link

Unavailable simulators are not ignored #192

Open mentoc3000 opened 4 years ago

mentoc3000 commented 4 years ago

Some of the simulators on my machine are unavailable. For instance, the iPad Pro 11 inch on iOS 12.2 is not available because I have not installed the iOS 12.2 simulator.

-- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-12-2 --
    iPhone 5s (739BB7D5-8286-4689-A851-B4BA054B62C6) (Shutdown) (unavailable, runtime profile not found)
    iPhone 6 Plus (8D83D9CF-F3E4-4E0B-91CE-B5B61118C70E) (Shutdown) (unavailable, runtime profile not found)
    iPhone 6 (1CAB72E7-FB16-4332-9913-2D049B41F46B) (Shutdown) (unavailable, runtime profile not found)
    iPhone 6s (F723FBFC-1B7D-46AE-A3D4-6DADBCD9C019) (Shutdown) (unavailable, runtime profile not found)
    iPhone 6s Plus (DDEB9CF5-5372-49CE-8763-CFD2C5A9B208) (Shutdown) (unavailable, runtime profile not found)
    iPhone SE (80A67194-40F8-4D87-AE03-317857492879) (Shutdown) (unavailable, runtime profile not found)
    iPhone 7 (8518BF4F-603D-402C-926F-C36965BB1F72) (Shutdown) (unavailable, runtime profile not found)
    iPhone 7 Plus (87C8C702-288A-453C-80C2-88014228CC90) (Shutdown) (unavailable, runtime profile not found)
    iPhone 8 (83656F90-DF97-4F11-B326-0D0948E07419) (Shutdown) (unavailable, runtime profile not found)
    iPhone 8 Plus (CB3C8968-1665-44A4-8077-AC188E5CA2FD) (Shutdown) (unavailable, runtime profile not found)
    iPhone X (7806903F-4764-4803-B3BC-AACEAFC654FD) (Shutdown) (unavailable, runtime profile not found)
    iPhone Xs (180ACBBA-8DA7-4BBA-BAE2-A796B33626E4) (Shutdown) (unavailable, runtime profile not found)
    iPhone Xs Max (5D5A05DF-FB90-4F42-989F-34783E5905B6) (Shutdown) (unavailable, runtime profile not found)
    iPhone Xʀ (FE57F614-FDC8-4E8D-91D3-DC2F53C0147E) (Shutdown) (unavailable, runtime profile not found)
    iPad Air (211981FE-79B2-4757-BC86-98C73EC6D836) (Shutdown) (unavailable, runtime profile not found)
    iPad Air 2 (411073E7-DCE4-43BC-BC8D-1965113C7C2F) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (9.7-inch) (63B00233-62E7-430E-852A-15027B79514D) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (12.9-inch) (5B62EA16-E870-4478-AA50-EA21A9FE66AD) (Shutdown) (unavailable, runtime profile not found)
    iPad (5th generation) (29C2BCB1-5C6F-43F8-8E63-C289C8D8AD9F) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (12.9-inch) (2nd generation) (B4E45AB1-4619-43EE-A883-BCE50D5CABB5) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (10.5-inch) (650E7EFA-70B4-4FB7-902F-3301C4F4AF65) (Shutdown) (unavailable, runtime profile not found)
    iPad (6th generation) (0BC8E995-8AE3-4454-B6A5-1D4D04A8DE90) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (11-inch) (2CFEE1B9-307A-4F93-B69E-F55C6DD3EE25) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (12.9-inch) (3rd generation) (4EBB73D2-699C-4CB3-AA74-CD15D8BC3043) (Shutdown) (unavailable, runtime profile not found)
    iPad Air (3rd generation) (4BD8A43D-5DD6-4E08-A0A2-077394ADB632) (Shutdown) (unavailable, runtime profile not found)
      {
        "availabilityError" : "runtime profile not found",
        "dataPath" : "\/Users\/jpsheehan\/Library\/Developer\/CoreSimulator\/Devices\/2CFEE1B9-307A-4F93-B69E-F55C6DD3EE25\/data",
        "logPath" : "\/Users\/jpsheehan\/Library\/Logs\/CoreSimulator\/2CFEE1B9-307A-4F93-B69E-F55C6DD3EE25",
        "udid" : "2CFEE1B9-307A-4F93-B69E-F55C6DD3EE25",
        "isAvailable" : false,
        "deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch-",
        "state" : "Shutdown",
        "name" : "iPad Pro (11-inch)"
      },

It looks like screenshots does not check for simulator availability and tries to pick unavailable devices sometimes. Here is the output of screenshots -v

[ +160 ms] Starting flutter daemon...
[  +99 ms] executing: flutter daemon
[+2739 ms] <== Starting device daemon...
[  +64 ms] <== [{"event":"daemon.connected","params":{"version":"0.5.3","pid":48113}}]
[  +35 ms] ==> [{"method":"device.enable","id":0}]
[   +1 ms] waiting for response: {method: device.enable, id: 0}
[ +205 ms] <== [{"id":0}]
[+5081 ms] executing: [./] sh -c ios-deploy -c || echo "no attached devices"
[ +149 ms] Starting flutter daemon... (completed in 8.3s)
[   +2 ms] ==> [{"method":"device.getDevices","id":1}]
[        ] waiting for response: {method: device.getDevices, id: 1}
[ +947 ms] <== [{"id":1,"result":[]}]
[   +4 ms] ==> [{"method":"emulator.getEmulators","id":2}]
[        ] waiting for response: {method: emulator.getEmulators, id: 2}
[ +162 ms] <== [{"id":2,"result":[{"id":"flutter_emulator","name":"flutter emulator","category":"mobile","platformType":"android"},{"id":"apple_ios_simulator","name":"iOS Simulator","category":"mobile","platformType":"ios"}]}]
[   +1 ms] daemonEmulator=id: flutter_emulator, name: flutter emulator, category: mobile, platformType: android
[        ] daemonEmulator=id: apple_ios_simulator, name: iOS Simulator, category: mobile, platformType: ios
[ +863 ms] executing: [./] xcrun simctl list devices --json
[  +50 ms] Warning: 'iPhone 11 Pro' has multiple iOS versions.
[        ]        : Using 'iPhone 11 Pro' with iOS version com.apple.CoreSimulator.SimRuntime.iOS-13-4 (ID: 00ACD004-977E-4F9F-AE52-A6B330F18DBF).
[   +2 ms] Warning: 'iPhone X' has multiple iOS versions.
[        ]        : Using 'iPhone X' with iOS version com.apple.CoreSimulator.SimRuntime.iOS-11-3 (ID: B2F2B29E-0A3D-48AF-AB2B-E03846A94ADE).
[   +2 ms] Warning: 'iPhone 8 Plus' has multiple iOS versions.
[        ]        : Using 'iPhone 8 Plus' with iOS version com.apple.CoreSimulator.SimRuntime.iOS-13-4 (ID: 6270DEE9-4A11-42E9-908B-1F485B90DE0F).
[        ] Warning: 'iPhone 8' has multiple iOS versions.
[        ]        : Using 'iPhone 8' with iOS version com.apple.CoreSimulator.SimRuntime.iOS-13-4 (ID: A7C8E98F-ACD4-4E2C-B0D4-F986B6B61A91).
[  +62 ms] executing: [./] chmod u+x /tmp/screenshots/resources/script/android-wait-for-emulator
[  +31 ms] executing: [./] chmod u+x /tmp/screenshots/resources/script/android-wait-for-emulator-to-stop
[  +18 ms] executing: [./] chmod u+x /tmp/screenshots/resources/script/simulator-controller
[  +24 ms] executing: [./] chmod u+x /tmp/screenshots/resources/script/sim_orientation.scpt
[   +9 ms] Warning: using default value 'phone' in fastlane directory.
[        ] Clearing images in ios/fastlane/screenshots/en-US for 'iPhone 11 Pro'...
[   +7 ms] Clearing images in ios/fastlane/screenshots/en-US for 'iPhone X'...
[        ] Clearing images in ios/fastlane/screenshots/en-US for 'iPhone 8 Plus'...
[  +16 ms] Warning: using default value 'phone' in fastlane directory.
[        ] Clearing images in ios/fastlane/screenshots/en-US for 'iPhone 8'...
[ +455 ms] executing: [./] xcrun simctl list devices --json
[  +95 ms] executing: [./] plutil -convert json -o - /Users/jpsheehan/Library/Developer/CoreSimulator/Devices/00ACD004-977E-4F9F-AE52-A6B330F18DBF/data/Library/Preferences/.GlobalPreferences.plist
Unhandled exception:
command failed: exitcode=1, cmd='plutil -convert json -o - /Users/jpsheehan/Library/Developer/CoreSimulator/Devices/00ACD004-977E-4F9F-AE52-A6B330F18DBF/data/Library/Preferences/.GlobalPreferences.plist', workingDir=.
#0      cmd (package:screenshots/src/utils.dart:361:5)
#1      getIosSimulatorLocale (package:screenshots/src/utils.dart:178:19)
#2      Screenshots.runTestsOnAll (package:screenshots/src/run.dart:226:40)
#3      Screenshots.run (package:screenshots/src/run.dart:127:11)
<asynchronous suspension>
#4      screenshots.<anonymous closure> (package:screenshots/src/run.dart:42:26)
#5      AppContext.run.<anonymous closure> (package:tool_base/src/base/context.dart:154:29)
#6      _rootRun (dart:async/zone.dart:1147:13)
#7      _CustomZone.run (dart:async/zone.dart:1040:19)
#8      _runZoned (dart:async/zone.dart:1582:10)
#9      runZoned (dart:async/zone.dart:1502:10)
#10     AppContext.run (package:tool_base/src/base/context.dart:153:18)
#11     runInContext (package:screenshots/src/context_runner.dart:16:24)
#12     screenshots (package:screenshots/src/run.dart:41:12)
#13     main (file:///Users/jpsheehan/.pub-cache/hosted/pub.dartlang.org/screenshots-2.1.1/bin/main.dart:122:25)
<asynchronous suspension>
#14     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#15     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
mentoc3000 commented 4 years ago

I was able to resolve this issue by running xcrun simctl delete unavailable to remove those unavailable devices from the list.