iOSのシミュレータを起動しようとして失敗した(Error: Could not find a device to launch. )時の対処法

時折、iOS SimulatorのDeviceが存在しない場合、Appiumは以下のようなエラーを出力します。

error: Failed to start an Appium session, err was: Error: Could not find a device to launch. You requested 'iPhone 5s (7.1 Simulator)', but the available devices were: ["iPhone 6 (8.0 Simulator) [1A161F50-9A23-4558-BD2F-2BFD2C58C319]"]
info: [debug] Error: Could not find a device to launch. You requested 'iPhone 5s (7.1 Simulator)', but the available devices were: ["iPhone 6 (8.0 Simulator) [1A161F50-9A23-4558-BD2F-2BFD2C58C319]"]
    at noDevicesError (/Users/:user/Documents/github/appium/lib/devices/ios/ios.js:1063:12)
    at null.<anonymous> (/Users/:user/Documents/github/appium/lib/devices/ios/ios.js:1069:18)
    at /Users/:user/Documents/github/appium/node_modules/appium-instruments/lib/instruments.js:101:7
    at ChildProcess.exithandler (child_process.js:694:7)
    at ChildProcess.EventEmitter.emit (events.js:107:17)
    at maybeClose (child_process.js:825:16)
    at Socket.<anonymous> (child_process.js:1042:11)
    at Socket.EventEmitter.emit (events.js:104:17)
    at Pipe.close (net.js:458:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find a device to launch. You requested 'iPhone 5s (7.1 Simulator)', but the available devices were: ["iPhone 6 (8.0 Simulator) [1A161F50-9A23-4558-BD2F-2BFD2C58C319]"])","origValue":"Could not find a device to launch. You requested 'iPhone 5s (7.1 Simulator)', but the available devices were: ["iPhone 6 (8.0 Simulator) [1A161F50-9A23-4558-BD2F-2BFD2C58C319]"]"},"sessionId":null}
info: <-- POST /wd/hub/session 500 1256.853 ms - 480
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"Appium","platformName":"ios","platformVersion":"7.1","deviceName":"iPhone 5s","app":APP_PATH,"raw":{"calendarFormat":"gregorian","language":"ja"}}}

この場合、指定したDeviceが存在しないため、シミュレータの起動までいきついていないことを意味します。

その対処法を以下にまとめます。

Shift + command + 2 、もしくはXcodeを開いた時のメニューバーから、Window->Devicesを選択すると以下の画面が表示されます。

skitch

ここで、上の画像の矢印の先にある”+”をクリックすると、以下の画像のようになります。

skitch-1

表示される項目を埋め、Createをクリックすると、シミュレータとして操作可能な端末が生成されます。
この操作により、先ほど表示されていたError: Could not find a device to launch.となっていた対象の端末を生成すると、通常は問題なくシミュレータの起動が可能になり、エラーを除くことが可能になります。

なお、以下のコマンドの出力結果として、現在利用な端末リストを確認することも可能です。

$ /Applications/Xcode.app/Contents/Developer/usr/bin/simctl list

結果

iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)
iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)
iPad Air (com.apple.CoreSimulator.SimDeviceType.iPad-Air)
Resizable iPhone (com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone)
Resizable iPad (com.apple.CoreSimulator.SimDeviceType.Resizable-iPad)
== Runtimes ==
iOS 7.0 (7.0.3 - 11B507) (com.apple.CoreSimulator.SimRuntime.iOS-7-0)
iOS 7.1 (7.1 - 11D167) (com.apple.CoreSimulator.SimRuntime.iOS-7-1)
iOS 8.0 (8.0 - 12A365) (com.apple.CoreSimulator.SimRuntime.iOS-8-0)
== Devices ==
-- iOS 7.0 --
    iPhone 4s (47B10E11-1CB9-4D4E-8A3A-2EFD70BE2845) (Shutdown)
    iPhone 5 (DE08596C-6E99-4319-9844-B6A327812921) (Shutdown)
    iPhone 5s (B92A68C4-6620-4E65-B627-1CB05DF65895) (Shutdown)
-- iOS 7.1 --
    iPhone 4s (DBCA909E-7293-44BD-9082-26796C819F58) (Shutdown)
    iPhone 5 (0562A7C4-BB27-4F0A-A83C-A99DAE4E5DCF) (Shutdown)
    iPhone 5s (0CEB836F-1261-4774-943D-E8FBD90533E7) (Shutdown)
-- iOS 8.0 --
    iPhone 4s (2341080A-3B98-4EAC-AAE3-6CEFF0BAD96A) (Shutdown)
    iPhone 5 (07DDEEA4-6F78-4CC5-8F80-8301BA54AE16) (Shutdown)
    iPhone 5s (A71396B2-3F26-434F-93C6-B4372943B5E8) (Shutdown)
    iPhone 6 (1A161F50-9A23-4558-BD2F-2BFD2C58C319) (Shutdown)

のようなものを得ることができるようになります。

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s