Run Ember.js in Phonegap

Running an Ember.js project built with Ember CLI in Phonegap is really simple.

Note: These instructions are based on projects built with CLI v 0.4.

1: Build your project, and copy the assets to your Phonegap www/ directory.

  ember build --environment=production

2: Include Ember.js project to Phonegap

Ensure vendor is included first.

<script type="text/javascript" src="js/ember-vendor.js"> </script>
<script type="text/javascript" src="js/ember-app.js"> </script>

3: Attach your Ember project to window

You can copy/paste these from your Ember projects dist/index.html, with two small changes. It is best to wait for the ‘deviceready’ event.

  • locationType should be set to “hash” or “none”; and
  • baseURL should be removed.
window.AppENV = {"environment":"production","locationType":"none","EmberENV":{"FEATURES":{}},"APP":{}};
window.EmberENV = window.AddoEmberENV.EmberENV;
window.AppEmber = require('app/app')['default'].create(AppENV.APP);

4: Done!

Your Ember.js project should be running in Phonegap with no further issues/configuration.