Getting Started - "ionic emulate ios" fails

I’m new to Ionic as well as Cordova. I’ve used PhoneGap in the past, but mostly PG Build and I never really did any compiling on my local machine.

I followed the steps in the Getting Started guide and ran ionic emulate ios, but I get this error text:

Aalaaps-iMac:myApp aalaap$ ionic emulate ios
Running emulate task...
Emulating app on platform ios
Generating config.xml from defaults for platform "ios"
Preparing ios project
Running on emulator for platform "ios" via command     "/Users/aalaap/Documents/Ionic/myApp/platforms/ios/cordova/run" --emulator
Error: An error occurred while emulating/deploying the ios project. Error: ios-sim was not found. Please download, build and install version 1.7 or greater from https://github.com/phonegap/ios-sim into your path. Or 'npm install -g ios-sim' using node.js: http://nodejs.org/

at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/emulate.js:67:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
Unable to emulate app on platform ios. Please see console for more info.

It suggests installing ios-sim, so I did that: sudo npm install -g ios-sim, but it only resulted in the following error:

npm http GET https://registry.npmjs.org/ios-sim
npm http 304 https://registry.npmjs.org/ios-sim

> ios-sim@1.8.2 preinstall /usr/local/lib/node_modules/ios-sim
> rake build

xcodebuild -project ios-sim.xcodeproj -configuration Release SYMROOT=build

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

rake aborted!
Command failed with status (69): [xcodebuild -project ios-sim.xcodeproj -con...]
/usr/local/lib/node_modules/ios-sim/Rakefile:7:in `block in <top (required)>'
Tasks: TOP => build
(See full trace by running task with --trace)
npm ERR! ios-sim@1.8.2 preinstall: `rake build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ios-sim@1.8.2 preinstall script.
npm ERR! This is most likely a problem with the ios-sim package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     rake build
npm ERR! You can get their info via:
npm ERR!     npm owner ls ios-sim
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.0.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "ios-sim"
npm ERR! cwd /Users/aalaap/Documents/Ionic/myApp
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.21
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/aalaap/Documents/Ionic/myApp/npm-debug.log
npm ERR! not ok code 0

I noticed that it suggests re-running the command as root via sudo, but that’s exactly what I did. I even tried sudo npm cache clear and re-ran the ios-sim install command, but the same error shows up.

I’m lost.

I may have fixed this myself.

I sort of gave up on Ionic and decided to follow the Cordova getting started guide instead. I ended up reinstalling Cordova, Homebrew, Ant, Android build-tools, some PATH changes, and a billion other dependencies in the process. Things are finally moving ahead, but I’m nowhere near anywhere that looks like where I want to be.

I managed to get the emulator to start up and run the sample app, so I guess we’re good!

Hey @aalaap, sorry for the trouble. We’ve been having reports of installation issues with Cordova dependencies recently, and with the new Cordova updates I think some stuff is breaking.

We are making it a priority to smooth out the installation and dependency process for Cordova, and indirectly Ionic. It’s a pain, and we know it!

I actually didn’t mind it in the end because I ended up discovering all those things I mentioned above. It was a good learning experience… as it should be with things like these!

I had the same original error. Once I installed ios-sim via npm as OP indicates, my followup error was different (see this stackoverflow link). My issue was that I was using the new xcode 6 beta, with which ios-sim does not currently work. However, as indicated in the stackoverflow response, this github fork of ios-sim accounts for the change in xcode 6 beta. I was able to successfully install using:

sudo npm install -g git://github.com/robovm/ios-sim

Posted in case someone else wants to use iconic over the next few months with the new xcode 6 beta. Hopefully ios-sim from phonegap gets updated to account for this issue. Until then thanks to robovm for the fix!

This just needs a little update on the ‘Getting Started’

sudo npm install ios-sim -g

is needed.

is this still the case with the latest ionic update? After ios-sim it fires up the simulator if I use “sudo ionic emulate ios” (why sudo) and has a black screen, eventually timing out.

Before ios-sim, I get the error.

** BUILD SUCCEEDED **

2014-09-22 08:53:45.989 ios-sim[9831:507] stderrPath: /Users/me/Projects/myapp/platforms/ios/cordova/console.log
2014-09-22 08:53:45.990 ios-sim[9831:507] stdoutPath: /Users/me/Projects/myapp/platforms/ios/cordova/console.log
2014-09-22 08:53:46.023 ios-sim[9831:507] -[__NSArrayM localizedDescription]: unrecognized selector sent to instance 0x7fcba9c02f90
2014-09-22 08:53:46.024 ios-sim[9831:507] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSArrayM localizedDescription]: unrecognized selector sent to instance 0x7fcba9c02f90’
*** First throw call stack:
(
0 CoreFoundation 0x00007fff905db25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8f5cce75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff905de12d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff90539272 forwarding + 1010
4 CoreFoundation 0x00007fff90538df8 _CF_forwarding_prep_0 + 120
5 ios-sim 0x0000000107418e29 -[iPhoneSimulator LoadSimulatorFramework:] + 245
6 ios-sim 0x000000010741a8e0 -[iPhoneSimulator runWithArgc:argv:] + 2271
7 ios-sim 0x000000010741acb2 main + 101
8 ios-sim 0x0000000107418ce4 start + 52
9 ??? 0x000000000000000b 0x0 + 11
)
libc++abi.dylib: terminating with uncaught exception of type NSException
/Users/me/Projects/myapp/platforms/ios/cordova/run: line 158: 9831 Abort trap: 6 ios-sim launch “$SIMULATOR_APP_PATH” --stderr “$CORDOVA_PATH/console.log” --stdout “$CORDOVA_PATH/console.log” $TARGET_FLAG --exit
Error: /Users/me/Projects/myapp/platforms/ios/cordova/run: Command failed with exit code 134
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)

Hi @sentient! Always I start, create a new app, I will have to do this? Type in Terminal “sudo npm install ios-sim -g”?

Hi @max! Every time we create a new project we have to type in Terminal “sudo npm install ios-sim -g”, like @sentient says?

You may also need to open Xcode and agreed to the Xcode license agreements

我…很多話想對你們說…辛苦了謝謝!!