Search code examples
cordovaionic-frameworkios-simulatorxcode7osx-elcapitan

Xcode 7 Invalid Device State - XPC_ERROR


When I run cordova emulate ios (or ionic emulate ios), I get an Invalid Device State Error code=159. If I leave the simulator open, reset the contents, and re-run the command, I do not get the above error but the simulator never finishes loading the app.

In both cases, the system logs hundreds of XPC_ERROR_CONNECTION_INTERRUPTED entries from instruments or mdworker. Here's the last few entires of a recent attempt:

Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: received XPC_ERROR_CONNECTION_INTERRUPTED trying to map database
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: received XPC_ERROR_CONNECTION_INTERRUPTED trying to map database
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: Database mapping failed with result -10822, retrying
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: received XPC_ERROR_CONNECTION_INTERRUPTED trying to map database
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: received XPC_ERROR_CONNECTION_INTERRUPTED trying to map database
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: Database mapping failed with result -10822, retrying
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: received XPC_ERROR_CONNECTION_INTERRUPTED trying to map database
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: received XPC_ERROR_CONNECTION_INTERRUPTED trying to map database
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: Database mapping failed with result -10822, retrying
Feb 21, 2016, 2:08:59 PM instruments[93351]: LaunchServices: received XPC_ERROR_CONNECTION_INTERRUPTED trying to map database
Feb 21, 2016, 2:08:59 PM com.apple.xpc.launchd[1]: Caller not allowed to perform action: instruments.93351, action = service submission, code = 1: Operation not permitted, uid = 503, euid = 503, gid = 20, egid = 20, asid = 100007
Feb 21, 2016, 2:09:30 PM com.apple.CoreSimulator.CoreSimulatorService[549]: Error Domain=com.apple.CoreSimulator.SimError Code=159 "Unable to lookup in current state: Shutdown" UserInfo={NSLocalizedDescription=Unable to lookup in current state: Shutdown}
Feb 21, 2016, 2:09:30 PM com.apple.CoreSimulator.CoreSimulatorService[549]: Error Domain=com.apple.CoreSimulator.SimError Code=159 "Unable to lookup in current state: Shutdown" UserInfo={NSLocalizedDescription=Unable to lookup in current state: Shutdown}
Feb 21, 2016, 2:09:30 PM com.apple.CoreSimulator.CoreSimulatorService[549]: Error looking up host support port
Feb 21, 2016, 2:09:32 PM com.apple.CoreSimulator.CoreSimulatorService[549]: Error Domain=com.apple.CoreSimulator.SimError Code=159 "Unable to lookup in current state: Shutdown" UserInfo={NSLocalizedDescription=Unable to lookup in current state: Shutdown}
Feb 21, 2016, 2:09:32 PM com.apple.CoreSimulator.CoreSimulatorService[549]: Error Domain=com.apple.CoreSimulator.SimError Code=159 "Unable to lookup in current state: Shutdown" UserInfo={NSLocalizedDescription=Unable to lookup in current state: Shutdown}
Feb 21, 2016, 2:09:32 PM com.apple.CoreSimulator.CoreSimulatorService[549]: Error looking up host support port

I know there are a few other posts on this but none seem to address my issue. Im running everything locally, permissions are correctly configured in the user directory. I've reproduced this error on Xcode 7.21 as well as 7.3, with using a firewall and without, with using node via nvm and on its own.

My current config:

Cordova CLI: 6.0.0
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.1
Ionic Version: 1.2.4-nightly-1917
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.5
ios-sim version: 5.0.6
OS: Mac OS X El Capitan 10.11.3
Node Version: v5.6.0
Xcode version: Xcode 7.3 Build version 7D141l

Some postings suggest this has to do with Time Machine and Spotlight. I have no clue, but if it helps - I'm currently not using Time Machine and I've placed the entire HD in TM's excluded folders. Lastly, from researching the 'could not store' log below, I added the /private/var/db/lsd folder...however it hasn't corrected the problem. This may be unrelated, but I'm not sure.

Feb 21, 2016, 3:06:28 PM com.apple.xpc.launchd[1]: Service only ran for 1 seconds. Pushing respawn out by 9 seconds.
Feb 21, 2016, 3:06:29 PM com.apple.usbmuxd[94227]: stopping.
Feb 21, 2016, 3:06:30 PM com.apple.usbmuxd[16479]: log filter changed from 4 to 6
Feb 21, 2016, 3:06:30 PM com.apple.usbmuxd[16479]: usbmuxd-364 on Aug  4 2015 at 14:36:18, running 64 bit
Feb 21, 2016, 3:07:37 PM lsd[295]: LaunchServices: Could not store lsd-identifiers file at /private/var/db/lsd/com.apple.lsdschemes.plist
Feb 21, 2016, 3:07:37 PM lsd[295]: LaunchServices: Could not store lsd-identifiers file at /private/var/db/lsd/com.apple.lsdschemes.plist
Feb 21, 2016, 3:08:27 PM syslogd[51]: ASL Sender Statistics

Thanks for your help


Solution

  • I realize you said permissions were correct, but this post seems to imply that a permissions problem may be the cause of it.

    http://zacvineyard.com/blog/2015/11/ionic-invalid-device-state-error-with-xcode-7-solved https://github.com/driftyco/ionic/issues/4052

    Also, have you tried opening X-code first, then navigating to the Ionic platforms/ios folder to open the project. From there, you can run the emulator.

    Regarding XPC errors. (This is completely separate from Ionic. It is an OSX problem).


    Ionic is starting the emulator using "LaunchServices" (which uses XPC). See more at:

    https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingXPCServices.html

    To resolve error "Database mapping failed with result -10822", you may want to try rebuilding your Launch Services database. See http://hints.macworld.com/article.php?story=20031215144430486

    (kLSServerCommunicationErr -10822 error is "There is a problem communicating with the server process that maintains the Launch >Services database.")

    Also, see https://discussions.apple.com/message/7040998#7040998. I'd also try "DiskUtility -> RepairPermissions"