Trying to get cordova sample running on iPhone

To run our Cordova sample on iOS, I’m using a Mac OS/X Maverics with Xcode 5.02 installed.

To add ios support in our compass application, from within the compass directory, issue:

cordova platform add ios

This went smoothly.

Next, building the project:

cordova build ios

This also went smoothly.


cordova run ios

This yielded:

Error: An error occurred while running the ios project.Error: ios-deploy was not found. Please download, build and install version 1.0.4 or greater from into your path. Or 'npm install -g ios-deploy' using node.js:

I opted for the 2nd option which seemed to go ok:

npm http GET
npm http 200
npm http GET
npm http 200

> ios-deploy@1.0.4 preinstall /usr/local/lib/node_modules/ios-deploy
> make ios-deploy

rm -rf *.app demo ios-deploy
gcc -o ios-deploy -framework CoreFoundation -framework MobileDevice -F/System/Library/PrivateFrameworks ios-deploy.c
/usr/local/bin/ios-deploy -> /usr/local/lib/node_modules/ios-deploy/ios-deploy
ios-deploy@1.0.4 /usr/local/lib/node_modules/ios-deploy

running cordova run ios ended with ‘Platform “ios” ran successfully.’ with one minor problem: Nothing happened on my ios device. No application was loaded to the device, let alone launched.

It immediately occurred to me that Apple won’t let you do shit without paying something first (With the iPhone, unlike Windows Phone 8 and Android, I couldn’t even get the phone OS operating without putting in a working SIM card, and also unlike them, you can’t just start uploading applications to your device without coughing up $99/year for a Apple Developer’s ID).

Luckily I had an Apple developer’s id I could use so I imported the certificate by opening the Xcode project that Cordova created and following the directions.

After than again cordova run ios, and now finally I saw the icon of the cordova compass application. Launching the application showed the basic html but the heading and geolocation were not displayed.

Looking at the cordova documentation for iOS for the compass, I saw that the following was needed in the config.xml file:

<feature name="Compass">
    <param name="ios-package" value="CDVLocation" />

so I added it. At the same opportunity I also added the following for the geolocation access:

<feature name="Geolocation">
    <param name="ios-package" value="CDVLocation" />

and repeated:

cordova build ios
corova run ios

and again, nothing. Tomorrow we go back to basics and try to make a minimal cordova sample of reading the compass.

By the way, to run the iOS emulator from the command line (at least on Cordova 3.2.0):

cordova run --emulator ios

Leave a Reply

Your email address will not be published. Required fields are marked *