$100 Proposal: window.cordova && IOS emulator

So I am having a couple of problems, of which I do NOT think should be hassles of any kind whatsoever in this day in age (Q2 of 2015).

Problem 1: I cannot get the sample Ionic app to startup and work in the IOS emulator, using my Macbook Air 2013.
Problem 2: I cannot get any 3rd party cordova plugins to be available – the “cordova” object is not showing up in the global namespace within the Ionic “lab” browser (e.g. ionic serve --lab).

Paypal ready to go. Will give initial payment of $25, and the remaining $75 upon resolution of these 2 problems.
To those who have resolved these 2 problems, this should be easy-peezy, slam dunk. Like taking candy from a baby ($100 for < 5 min of work).

It simply blows my mind how difficult the most trivial, easy problems is really this hard. Please prove me wrong. Thanks. -Albert

I think this is going to be difficult for anyone since no one has access to your computer but:

Problem 1: could you run ionic info and share what is shown? Does the emulator open? Do you get an error message?

Problem 2: cordova is not available in the browser. You will see a 404 pointing to cordova.js which is only available when you run it on a device. There is an extensión to run cordova projects on Chrome: http://emulate.phonegap.com/ so you might want to give it a try.

Hey joseadrian – thanks for the quick response. Ionic info:

OS: Mac OS X Yosemite
Node Version: v0.10.26
Cordova CLI: 4.3.0
Ionic Version: 1.0.0-rc.3
Ionic CLI Version: 1.3.19
Xcode version: Xcode 6.1.1 Build version 6A2008a
ios-sim version: 3.1.1
ios-deploy version: Not installed

Re: emulator opening, I first get these 2 messages:
2015-04-13 21:12:16.051 ios-sim[1236:17065] stderrPath: /Users/albertchang/Desktop/practice/whatsthat/platforms/ios/cordova/console.log
2015-04-13 21:12:16.051 ios-sim[1236:17065] stdoutPath: /Users/albertchang/Desktop/practice/whatsthat/platforms/ios/cordova/console.log

The Xcode emulator does open, but the screen simply stays at the home screen and does NOT enter the Ionic app. After about 30 seconds, I get the following error in the CLI:
Session could not be started: Error Domain=DTiPhoneSimulatorErrorDomain Code=2 “Simulator session timed out.” UserInfo=0x7ff93b7417c0 {NSLocalizedDescription=Simulator session timed out.}
Error code 1 for command: ios-sim with args: launch,/Users/albertchang/Desktop/practice/whatsthat/platforms/ios/build/emulator/whatsthat.app,–devicetypeid,com.apple.CoreSimulator.SimDeviceType.iPhone-6,–stderr,/Users/albertchang/Desktop/practice/whatsthat/platforms/ios/cordova/console.log,–stdout,/Users/albertchang/Desktop/practice/whatsthat/platforms/ios/cordova/console.log,–exit
Error: /Users/albertchang/Desktop/practice/whatsthat/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:131: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)

*************** Problem 2: this whole time I was under the impression that the cordova object would be visible under the window object, despite not being functionally accessible, e.g. console.log(window.cordova). I just downloaded the chrome extension. trying it out now…

///////////// As mentioned before, these errors are ubiquitous within this forum.
Thanks. -Albert

I always had had this problem. I got the exact (not really, i don’t get the messages after session could not be started… :() same errors and I think I have a simple solution

  1. First, open the simulator and wait until the simulator is loaded or run the command ionic run ios
  2. You will get those *messages
  3. run ìonic run ios` again if you already have done it
  4. Your app will open

I wanted to make a video showing that this actually works but since I’ve already tried it, the app opens at the first attempt :laughing:


2015-04-13 23:49:22.130 ios-sim[2956:37063] stderrPath: /Users/joseadrian/Developer/ionic/vetsnear.me/platforms/ios/cordova/console.log
2015-04-13 23:49:22.131 ios-sim[2956:37063] stdoutPath: /Users/joseadrian/Developer/ionic/vetsnear.me/platforms/ios/cordova/console.log
Session could not be started: Error Domain=DTiPhoneSimulatorErrorDomain Code=2 “Simulator session timed out.” UserInfo=0x7fd793c08110 {NSLocalizedDescription=Simulator session timed out.}

yeah it’s really weird. Still cannot get it to run despite doing the alternate approach: run IOS simulator first, then use “ionic run ios”, or even running “ionic run ios” first. Here are the other things I have done, compliments of all the vast amount of instructions and advice within this forum:

  1. Reset Content and Settings (and then hit Reset button)
  2. chmod -R 777 [project root folder]
  3. used “sudo ionic …” for almost every command (except adding plugins, e.g. ionic plugin add [plugin address])

By the way, this was the last error message I got:

“ERROR running one or more of the platforms: Error: /Users/albertchang/Desktop/practice/whatsthat/platforms/ios/cordova/run: Command failed with exit code 2
You may not have the required environment or OS to run this project”

Try @larpo’s solution :

It looks like it is a permission problem.

I am officially retiring this problem, as I am now exiting the world of JS and getting into Swift. I have been burned way too many times with frameworks that purport to do this and that, and shit like this – as basic and trivial as they are – persist as complicated problems to solve.

Thanks for the help joseadrian. Do you have a PayPal acct? i’d like to at least give you the $25 despite me not being able to resolve these issues.

1 Like

Last attempt.

The only difference between us is the node version. Could that be?

OS: Mac OS X Yosemite
Node Version: v0.12.0
Cordova CLI: 4.3.0
Ionic CLI Version: 1.3.19
Xcode version: Xcode 6.1.1 Build version 6A2008a
ios-sim version: 3.1.1
ios-deploy version: 1.4.0 # this doesn’t matter right now

Try running (also change ionic with cordova since ionic is on top of it)

ionic emulate ios --target=“iPhone4”

ionic emulate ios

ionic emulate ios -lcs

Using XCode

  • Open the *.xcodeproj inside platforms/ios
  • Build and run

If you get an alert Domain = FBSOpenApplicationErrorDomain, Code = 4

Go to iOS Simulator > Reset Content and Settings > Build and run from xCode

If you see a blank page run or a message on the xCode console: Failed to load webpage with error: Could not connect to the server run

ionic prepare ios

Build and run form xCode

I really hope you can start the app on iOS. And yeah, I do have one account. Do I send you the email?

I need your email address (at least an email address that I can paypal to).

For the time being, I am installing node .12 on my 2nd laptop. For the record, I have attempted to get the emulator running and getting the cordova object to be available (which I guess is a non-issue at this point) on my other laptop as well as the one i’m currently using now. Also, I had the latest node 0.12 on my previous laptop. All, in all, I have experienced the same exact results on both laptops. We’ll see how node 0.12 will go after it finishes installing here.

I reinstalled cordova because when I tried to run ìonic start …` I got errors about .plugman and some cordova plugins.

Here are two demos: using xCode and ionic

I will try this tomorrow. For the time being, you should see $50 added to your PayPal account. Thanks for all your time. -Albert