Ionic emulate Ios fails to run The session does not open my app

Ionic emulate ios failed on Mac OS Yosemite. Their have some cases were the ios device emulated, but shortly after the terminal console shoots up the error message below.

** BUILD SUCCEEDED **

No target specified for emulator. Deploying to iPhone-6 simulator An error was encountered processing the command (code=146): Invalid device state An error was encountered processing the command (code=146): Exception encountered connecting to CoreSimulatorBridge: Unable to connect to CoreSimulatorBridge ENOENT, no such file or directory '/Users/yay/Library/Logs/CoreSimulator/2CAA2C39-7F22-4AF2-BBDE-86609188F37C/system.log' Error code 1 for command: ios-sim with args: launch,/Users/yay/code/myApp/platforms/ios/build/emulator/myApp.app,--devicetypeid,com.apple.CoreSimulator.SimDeviceType.iPhone-6,--stderr,/Users/yay/code/myApp/platforms/ios/cordova/console.log,--stdout,/Users/yay/code/myApp/platforms/ios/cordova/console.log,--exit Error: /Users/yay/code/myApp/platforms/ios/cordova/run: Command failed with exit code 2 at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23) at ChildProcess.emit (events.js:110:17) at maybeClose (child_process.js:1015:16) at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

Do NOT use sudo when creating or building the project.

Please see https://github.com/driftyco/ionic/issues/4052

I've encountered this issue before, and I believe you messed up with your permission. However, I managed to solve it by reinstall everything from scratch (NOT reformat OS). I suggest you may try to remove all your Xcode, ionic, cordova, and ios-sim content and reinstall again.

  1. Delete your Xcode from your Mac OS.
  2. Remove everything inside:

    • /usr/local/bin
    • /usr/local/include
    • /usr/local/lib/dtrace
    • /usr/local/share/man/man1
    • /usr/local/share/systemtap/tapset/
  3. Delete the folder:

    • /usr/local/lib/node_modules

Once you done the instruction above, kindly use your spotlight to search for keywords such as node, cordova, ionic, etc... to see whether it is still exist or not. Please also ensure yourApp within your Users/username folder is deleted.

You may also try to use your terminal input:

npm -v
cordova -v
ionic -v

It will shows nothing/not found if you've deleted everything completely.

Now you can download and install Xcode from App Store, and wait for Xcode is fully installed in your Mac, then proceed to here to start again your ionic project.

Lastly, once you begin to create an ionic project, by right you no need to use any sudo commands anymore in creating or building this project.

Example:

ionic build ios

Instead of:

sudo ionic build ios

It should be working unless you are not the root user.

Happy coding and have a nice day! :D