Getting an error I did not before around Instruments crashing

I’m able to run the sample ruby script against the provide app using Appium from the command line just fine. I previously was able to run my company’s app from the command line and through the inspector.

Now my company’s app fails and crashes on start up due to Instruments. There were recently changes to the mobile project that I’m not entirely aware of but I’ve reached out to our mobile devs about that.

Can you tell from this log if something is wrong? This is the server log out put from running a test

Last login: Thu Apr  2 17:11:36 on ttys000
Companys-MacBook-Pro-2:~ mk$ appium
info: Welcome to Appium v1.3.6 (REV 004f52f249d3513809e7d0734d9205d1fec19f8e)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"iOS","versionNumber":"8.1","deviceName":"iPhone 6","app":"/Users/mk/code/company-ios/Company/CompanyTests/appium_tests/app/Company.app"}}
info: Client User-Agent string: Ruby
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : versionNumber
info: [debug] Using local app from desired caps: /Users/mk/code/company-ios/Company/CompanyTests/appium_tests/app/Company.app
info: [debug] Creating new appium session 3912c2d1-ccdf-4896-884b-b17a289c187d
info: [debug] Removing any remaining instruments sockets
info: [debug] Cleaned up instruments socket /tmp/instruments_sock
info: [debug] Setting Xcode folder
info: [debug] Setting Xcode version
info: [debug] Setting iOS SDK Version
info: [debug] Getting sdk version from xcrun with a timeout
info: [debug] iOS SDK Version set to 8.2
info: [debug] Checking whether instruments supports our device string
info: [debug] Getting list of devices instruments supports
info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.2","iOSSDKVersion":"8.2","deviceName":"iPhone 6","platformVersion":null}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 6 (8.2 Simulator)'
info: [debug] iOS sim UDID is F90ACA1A-A657-4E1A-BCE2-A2178FB50C51
info: [debug] Detecting automation tracetemplate
info: [debug] Not auto-detecting udid, running on sim
info: [debug] Could not parse plist file (as binary) at /Users/mk/code/company-ios/Company/CompanyTests/appium_tests/app/Company.app/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
info: [debug] Could not parse plist file (as XML) at /Users/mk/code/company-ios/Company/CompanyTests/appium_tests/app/Company.app/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings assuming it doesn't exist
info: [debug] Getting bundle ID from app
info: [debug] Parsed app Info.plist (as binary)
info: [debug] Creating instruments
info: On some xcode 6 platforms, instruments-without-delay does not work. If you experience this, you will need to re-run appium with the --native-instruments-lib flag
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/mk/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/usr/local/Cellar/node/0.12.0/bin/node","commandProxyClientPath":"/usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js","instrumentsSock":"/tmp/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false,"autoDismissAlerts":false,"sendKeyStrategy":"oneByOne"}
...o: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
info: [debug] Dynamic bootstrap path: /Users/mk/Library/Application Support/appium/bootstrap/bootstrap-dea1a1242b3bfb9b.js
info: [debug] Reusing dynamic bootstrap: /Users/mk/Library/Application Support/appium/bootstrap/bootstrap-dea1a1242b3bfb9b.js
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.2","iOSSDKVersion":"8.2","deviceName":"iPhone 6","platformVersion":null}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 6 (8.2 Simulator)'
info: [debug] We're on iOS7.1+ so forcing defaultDevice on
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.2","iOSSDKVersion":"8.2","deviceName":"iPhone 6","platformVersion":null}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 6 (8.2 Simulator)'
info: [debug] Parsed app Info.plist (as binary)
info: [debug] Wrote new app Info.plist with device type
info: [debug] Checking whether we need to set app preferences
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iOS Simulator
info: [debug] Killing any other simulator daemons
info: [debug] Cleaning sim data files
info: Executing: xcrun simctl erase F90ACA1A-A657-4E1A-BCE2-A2178FB50C51 with timeout 2000
info: [debug] Cleaning app data files
warn: Applications directory /Users/mk/Library/Developer/CoreSimulator/Devices/F90ACA1A-A657-4E1A-BCE2-A2178FB50C51/data/Applications doesn't exist. Have you run this simulator before?
info: Couldn't find app directories to delete. Probably it's not installed
info: [debug] Not setting locale
info: [debug] No iOS / app preferences to set
info: [debug] Starting iOS 8.* simulator log capture
info: [debug] Not pre-launching simulator
info: [debug] No device id or app, not installing to real device.
info: [debug] Starting command proxy.
info: [debug] Instruments socket server started at /tmp/instruments_sock
info: [debug] Starting instruments
info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (8.2 Simulator)
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 6 (8.2 Simulator)" "/Users/mk/code/company-ios/Company/CompanyTests/appium_tests/app/Company.app" -e UIASCRIPT "/Users/mk/Library/Application Support/appium/bootstrap/bootstrap-dea1a1242b3bfb9b.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib","LIB_PATH":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6"}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: Failed looking up pid of launched process
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #1
info: [debug] Killall iOS Simulator
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (8.2 Simulator)
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 6 (8.2 Simulator)" "/Users/mk/code/company-ios/Company/CompanyTests/appium_tests/app/Company.app" -e UIASCRIPT "/Users/mk/Library/Application Support/appium/bootstrap/bootstrap-dea1a1242b3bfb9b.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib","LIB_PATH":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6"}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: Failed looking up pid of launched process
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #2
info: [debug] Killall iOS Simulator
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (8.2 Simulator)
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 6 (8.2 Simulator)" "/Users/mk/code/company-ios/Company/CompanyTests/appium_tests/app/Company.app" -e UIASCRIPT "/Users/mk/Library/Application Support/appium/bootstrap/bootstrap-dea1a1242b3bfb9b.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib","LIB_PATH":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6"}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 8.) : Failed to launch process with bundle identifier 'com.company.ios.app'
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #3
info: [debug] Got the FBSOpenApplicationError, not killing the sim but leaving it open so the app will launch
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (8.2 Simulator)
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 6 (8.2 Simulator)" "/Users/mk/code/company-ios/Company/CompanyTests/appium_tests/app/Company.app" -e UIASCRIPT "/Users/mk/Library/Application Support/appium/bootstrap/bootstrap-dea1a1242b3bfb9b.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib","LIB_PATH":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6"}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: Failed looking up pid of launched process
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] We exceeded the number of retries allowed for instruments to successfully start; failing launch
info: [debug] Stopping iOS log capture
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iOS Simulator
info: [debug] Killing any other simulator daemons
info: [debug] Cleaning sim data files
info: Executing: xcrun simctl erase F90ACA1A-A657-4E1A-BCE2-A2178FB50C51 with timeout 2000
info: [debug] Cleaning app data files
warn: Applications directory /Users/mk/Library/Developer/CoreSimulator/Devices/F90ACA1A-A657-4E1A-BCE2-A2178FB50C51/data/Applications doesn't exist. Have you run this simulator before?
info: Couldn't find app directories to delete. Probably it's not installed
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Instruments crashed on startup
info: [debug] Error: Instruments crashed on startup
    at Instruments.onInstrumentsExit (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:389:31)
    at null.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:308:12)
    at ChildProcess.emit (events.js:110:17)
    at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null}
info: <-- POST /wd/hub/session 500 44558.012 ms - 182

From your log:

This makes me think you have a bad Simulator entry. Can you try deleting all of the Simulator devices, and then creating 1 that you’d like to use and trying again? If you still see the same error, you could have some garbage data in simulator. To remove that use the ‘xcrun simctl list’ command in a Terminal window. If you see devices in there that don’t show up in the GUI, you’ll need to delete them with the ‘xcrun simctl delete uuid’ command. (Replace ‘uuid’ with the actual uuid of course.)

I’m wondering if you might be able to help me. I’ve followed this post before with successful results. For some reason, my tests began to fail yesterday with the same error message as above. (Have you run this simulator before? info: Couldn’t find app directories to delete. Probably it’s not installed)

I used "xcrun simctl delete " to start my simulator list from scratch, and then I added a simulator through Xcode again. If I run “xcrun simctl list” I get the following:

    == Device Types ==
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 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s)
iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)
iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)
iPad Air (com.apple.CoreSimulator.SimDeviceType.iPad-Air)
iPad Air 2 (com.apple.CoreSimulator.SimDeviceType.iPad-Air-2)
Apple Watch - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm)
Apple Watch - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm)
== Runtimes ==
iOS 7.1 (7.1 - 11D167) (com.apple.CoreSimulator.SimRuntime.iOS-7-1) (unavailable, failed to open liblaunch_sim.dylib)
iOS 8.1 (8.1 - 12B411) (com.apple.CoreSimulator.SimRuntime.iOS-8-1) (unavailable, failed to open liblaunch_sim.dylib)
iOS 8.2 (8.2 - 12D508) (com.apple.CoreSimulator.SimRuntime.iOS-8-2) (unavailable, failed to open liblaunch_sim.dylib)
iOS 8.3 (8.3 - 12F70) (com.apple.CoreSimulator.SimRuntime.iOS-8-3) (unavailable, failed to open liblaunch_sim.dylib)
iOS 8.4 (8.4 - 12H141) (com.apple.CoreSimulator.SimRuntime.iOS-8-4) (unavailable, failed to open liblaunch_sim.dylib)
iOS 9.0 (9.0 - 13A340) (com.apple.CoreSimulator.SimRuntime.iOS-9-0)
watchOS 2.0 (2.0 - 13S343) (com.apple.CoreSimulator.SimRuntime.watchOS-2-0)
== Devices ==
-- iOS 7.1 --
-- iOS 8.1 --
-- iOS 8.2 --
-- iOS 8.3 --
-- iOS 8.4 --
-- iOS 9.0 --
    iPhone 5s (590AC234-E6F6-4D84-BE23-A9ACED6B0305) (Shutdown)
-- watchOS 2.0 --
== Device Pairs ==

When I attempt to run my tests (which have worked for months) via the simulator, it tries three times and eventually crashes with the “Instruments crashed on startup” error. Also, I do see the “simctl erase” messages in the logs:

info: node-simctl: Executing: xcrun with args: simctl erase 590AC234-E6F6-4D84-BE23-A9ACED6B0305 and timeout: 2000
info: node-simctl: Executing: xcrun with args: simctl erase 590AC234-E6F6-4D84-BE23-A9ACED6B0305 and timeout: 2000
info: node-simctl: Executing: xcrun with args: simctl erase 590AC234-E6F6-4D84-BE23-A9ACED6B0305 and timeout: 2000

Any assistance would be greatly appreciated, as my work for iOS is currently blocked. Thank you!

Those ‘simctl erase’ commands look like they pass. Could you post the log where the failure is?

Also, what has changed? Did you update Xcode recently or anything like that?

Thanks for your reply. I have not updated Xcode since I upgraded to 7.0.1 a few weeks ago, and I really can’t think of any other changes that I’ve made that would break anything.

I did try to make a few adjustments today to see if I could fix this issue. (i.e. deleted existing simulator and created a new one, modified desired capabilities). I’m still having problems, but it’s a different problem this time. The logs say the following:

error: Failed getting devices. Err: Error: Command failed: /bin/sh -c ‘/Applications/Xcode.app/Contents/Developer/usr/bin/instruments’ -s devices
. Stdout: . Stderr: .

error: Could not find a device to launch. You requested ‘cindy_iPhone_5s (9.0)’, but the available devices were:

error: Failed to start an Appium session, err was: Error: Could not find a device to launch. You requested ‘cindy_iPhone_5s (9.0)’, but the available devices were:

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 ‘cindy_iPhone_5s (9.0)’, but the available devices were: )”,“origValue”:“Could not find a device to launch. You requested ‘cindy_iPhone_5s (9.0)’, but the available devices were: ”},“sessionId”:null}

The full log is here:

 MacbookPro:~ cindy$ info: Welcome to Appium v1.4.11 (REV 8cf8311f00e59a2b10fde1834fcf6d5ace6fbcd0)
    info: Appium REST http interface listener started on 0.0.0.0:4723
    info: Console LogLevel: debug
    info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/cindy/Desktop/cindyM.app","platformVersion":"9.0","waitForAppScript":true,"platformName":"iOS","device":"iPhone 5s","deviceName":"cindy_iPhone_5s","platform":"MAC","autoAcceptAlerts":true}}
    info: Client User-Agent string: Apache-HttpClient/4.3.6 (java 1.5)
    info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : device, platform
    info: [debug] Using local app from desired caps: /Users/cindy/Desktop/cindyM.app
    info: [debug] Creating new appium session 61685481-5851-4339-9851-df5291f9946e
    info: [debug] Removing any remaining instruments sockets
    info: [debug] Cleaned up instruments socket /tmp/instruments_sock
    info: [debug] Setting Xcode version
    info: [debug] Xcode version set to 7.0.1
    info: [debug] Setting iOS SDK Version
    info: [debug] iOS SDK Version set to 9.0
    info: [debug] Checking whether instruments supports our device string
    info: [debug] Getting list of devices instruments supports
    info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
    error: Failed getting devices. Err: Error: Command failed: /bin/sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/instruments' -s devices
    . Stdout: . Stderr: .
    info: [debug] Getting list of devices instruments supports
    info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
    info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"7.0.1","iOSSDKVersion":"9.0","deviceName":"cindy_iPhone_5s","platformVersion":"9.0"}
    info: [debug] fixDevice is on
    info: [debug] Final device string is: 'cindy_iPhone_5s (9.0)'
    error: Could not find a device to launch. You requested 'cindy_iPhone_5s (9.0)', but the available devices were: []
    info: [debug] Cleaning up appium session
    error: Failed to start an Appium session, err was: Error: Could not find a device to launch. You requested 'cindy_iPhone_5s (9.0)', but the available devices were: []
    info: [debug] Error: Could not find a device to launch. You requested 'cindy_iPhone_5s (9.0)', but the available devices were: []
        at noDevicesError (/usr/local/lib/node_modules/appium/lib/devices/ios/ios.js:1121:10)
        at [object Object].<anonymous> (/usr/local/lib/node_modules/appium/lib/devices/ios/ios.js:1127:16)
        at /usr/local/lib/node_modules/appium/node_modules/async/lib/async.js:522:46
        at /usr/local/lib/node_modules/appium/node_modules/async/lib/async.js:251:17
        at /usr/local/lib/node_modules/appium/node_modules/async/lib/async.js:148:21
        at /usr/local/lib/node_modules/appium/node_modules/async/lib/async.js:248:21
        at /usr/local/lib/node_modules/appium/node_modules/async/lib/async.js:612:34
        at /usr/local/lib/node_modules/appium/node_modules/async/lib/async.js:513:25
        at /usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:117:7
        at ChildProcess.exithandler (child_process.js:194:7)
        at emitTwo (events.js:87:13)
        at ChildProcess.emit (events.js:172:7)
        at maybeClose (internal/child_process.js:818:16)
        at Socket.<anonymous> (internal/child_process.js:319:11)
        at emitOne (events.js:77:13)
        at Socket.emit (events.js:169:7)
        at Pipe._onclose (net.js:469: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 'cindy_iPhone_5s (9.0)', but the available devices were: [])","origValue":"Could not find a device to launch. You requested 'cindy_iPhone_5s (9.0)', but the available devices were: []"},"sessionId":null}

So it’s telling me that there are no available devices. However, when I run “xcrun simctl list” I get the following:

== Device Types ==
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 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s)
iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)
iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)
iPad Air (com.apple.CoreSimulator.SimDeviceType.iPad-Air)
iPad Air 2 (com.apple.CoreSimulator.SimDeviceType.iPad-Air-2)
Apple Watch - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm)
Apple Watch - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm)
== Runtimes ==
iOS 7.1 (7.1 - 11D167) (com.apple.CoreSimulator.SimRuntime.iOS-7-1) (unavailable, failed to open liblaunch_sim.dylib)
iOS 8.1 (8.1 - 12B411) (com.apple.CoreSimulator.SimRuntime.iOS-8-1) (unavailable, failed to open liblaunch_sim.dylib)
iOS 8.2 (8.2 - 12D508) (com.apple.CoreSimulator.SimRuntime.iOS-8-2) (unavailable, failed to open liblaunch_sim.dylib)
iOS 8.3 (8.3 - 12F70) (com.apple.CoreSimulator.SimRuntime.iOS-8-3) (unavailable, failed to open liblaunch_sim.dylib)
iOS 8.4 (8.4 - 12H141) (com.apple.CoreSimulator.SimRuntime.iOS-8-4)
iOS 9.0 (9.0 - 13A340) (com.apple.CoreSimulator.SimRuntime.iOS-9-0)
watchOS 2.0 (2.0 - 13S343) (com.apple.CoreSimulator.SimRuntime.watchOS-2-0)
== Devices ==
-- iOS 7.1 --
-- iOS 8.1 --
-- iOS 8.2 --
-- iOS 8.3 --
-- iOS 8.4 --
-- iOS 9.0 --
    cindy_iPhone_5s (497E071D-6C3D-4CD1-B314-C32F100D185D) (Shutdown)
-- watchOS 2.0 --
== Device Pairs == 

And if I navigate to /usr/bin/ and run “instruments -s” via the terminal, I get this:

Known Devices:
MacbookPro [F5EC806D-A483-55D5-906B-A339E7B0EBC4]
cindy_iPhone_5s (9.0) [497E071D-6C3D-4CD1-B314-C32F100D185D]
Known Templates:
...

So it’s not like the device isn’t there, but it seems like Appium isn’t seeing it for some reason. Thanks in advance for your help. I really appreciate it. (And I’ll stop messing with it for a while… )

I think I see a problem but I haven’t figured out a fix yet. Can you open a terminal and type, “which instruments” (without the quotes), and then post the output? I’m thinking it is different than what I quoted above from your log.

1 Like

Found it:

1 Like

Thanks for your reply! I apologize for my delayed response.

I did get two different values when I typed “which instruments” and “xcrun -find instruments”:

MacbookPro:appium cindy$ xcrun -find instruments
/Applications/Xcode.app/Contents/Developer/usr/bin/instruments

MacbookPro:appium cindy$ which instruments
/usr/bin/instruments

I added the DEVELOPER_DIR environment variable to bash_profile like so: export DEVELOPER_DIR=/Application/Xcode.app/Contents/Developer, and I cleared the cache as suggested in the link that you posted above. I still got the error message about an empty array of available devices.

I then tried to resolve the issue by running the following, which was reported as a working solution elsewhere:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
I’m still getting the error message about an empty array of available devices.

Clearly I’m still doing something wrong… If I type “which instruments” after successfully updating the path that points to instruments, would I still expect to see /usr/bin/instruments, or would I expect to see the path that I see when I type “xcrun -find instruments”?

Thanks so much for your help. It is truly appreciated.

Correct me if I’m wrong, but it seems that /usr/bin/instruments is the working version of instruments on your current machine. Have you tried something like:

xcode-select -switch /usr/bin/instruments

or

export DEVELOPER_DIR=/usr/bin/instruments

Seems like you could always switch it back to the Xcode.app version if you need to.

1 Like

I think /usr/bin/instruments is the working version of instruments on my machine. If I run which instruments, that is the path that is returned.

I tried running xcode-select -switch /usr/bin/instruments, but I got an error that said invalid developer directory '/usr/bin/instruments'

I tried export DEVELOPER_DIR=/usr/bin/instruments and could not start an Appium session. I got the following errors:

error: Could not determine Xcode version:Could not get Xcode version. /usr/bin/Info.plist does not exist on disk.

error: Could not determine iOS SDK version

error: Failed to start an Appium session, err was: Error: Could not get Xcode version. /usr/bin/Info.plist does not exist on disk.

info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not get Xcode version. /usr/bin/Info.plist does not exist on disk.)”,“origValue”:“Could not get Xcode version. /usr/bin/Info.plist does not exist on disk.”},“sessionId”:null}

Reverting back to export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer got rid of that error and allows an Appium session to be started, but I still get the error that I initially posted about:

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 ‘cindy_iPhone_5s (9.0)’, but the available devices were: )”,“origValue”:“Could not find a device to launch. You requested ‘cindy_iPhone_5s (9.0)’, but the available devices were: ”},“sessionId”:null}

So here’s where I’m at right now:

  • I deleted my simulator and created a new one via Xcode (just in case).

  • If I manually navigate to /Applications/Xcode.app/Contents/Developer/usr/bin/instruments, I can confirm that my simulator is present in instruments by running instruments -s via the terminal.

  • If I manually navigate to /usr/bin/instruments, I can confirm that my simulator is present in instruments by running instruments -s via the terminal. (Earlier I mentioned that /usr/bin/instruments is called an invalid developer directory, but I can access it. Maybe there’s something here?)

  • The Appium log says the following: info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments

  • When I run xcrun simctl list, I see my simulator in the list.

  • When I run xcrun -find instruments, this is returned: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments

  • The Appium log matches the one that I posted prior to my last post.

If you have any other ideas, I’ll give them a shot. Otherwise I might just try uninstalling Xcode and starting from scratch. My tests used to run without a hitch, so maybe that would help. Again, thank you for your time and assistance. It is very much appreciated.

Hmm. This is a stumper. I do think that there is something wrong with the instruments in your Xcode. I agree that at this point you need to try installing Xcode from scratch. You also might create a new user on your Mac & try it from there. This line is what’s failing:

error: Failed getting devices. Err: Error: Command failed: /bin/sh -c ‘/Applications/Xcode.app/Contents/Developer/usr/bin/instruments’ -s devices
. Stdout: . Stderr: .

And it’s like the Stdout and Stderr are being redirected. Very strange. I’ve tried running that command (including the /bin/sh -c) on my machine but it does not work. Leaving off the /bin/sh -c, however, works fine for me on Xcode 7, OS X 10.10.5.

One last thing to try would be to upgrade Appium to 1.4.13. This is what I’m currently using and I’m not having any problems.

1 Like

I’ve never been so happy to see a simulator boot up in my life! :smiley:

After uninstalling Xcode from scratch and reinstalling it - and then upgrading to Appium 1.4.13 - I’m finally able to recognize and run the simulator.

I have no idea why this happened and I probably never will, but I did notice something odd in the process of making these updates. After I reinstalled Xcode, I ran xcrun simctl list to see what would come up. I got a list of simulators, but it looks as if version 9.0 is only listed under tvOS and not iOS. (There used to be a section for 9.0, but now it goes from 8.4 to 9.1) I had Xcode configured for a deployment target of 9.0, and that’s also the version that I had in my Desired Capabilities. Maybe there was an update that got pushed and rendered that option obsolete? (I’ve since updated both to 9.1)

Anyway, it’s working now and I can’t thank you enough for your help. I’m so happy to not be blocked on my work anymore. Thanks again!!