Reputation: 438
I noticed today that: sudo npm update -g phonegap showed that v3.5 was available. After doing this update, phonegap -v returns: 3.5.0-0.20.4
I then proceeded to create a sample app using the Phonegap CLI:
At this point, the sample app launches. However, deviceready event never gets called. (I added some alert code and can see that the app.initialize() and app.bindEvents() get called. But onDeviceReady never gets called. I was also able to reproduce this with an Android build.
A few weeks ago, I went through exactly the same process with the previous version of Phonegap (v3.4.0-0.20.0) to create a HelloWorld340 which works fine and does call the onDeviceReady function.
I realize that the Phonegap 3.5.0 packaging of cordova 3.5.0 has only been out a few days. Perhaps it's a bug in the packaging? Anyone have any ideas or solutions.
Thanks!
Upvotes: 0
Views: 2226
Reputation: 438
More interesting observations over the past few days. I went through the process to create a few more projects. (I'm migrating a bunch of old PhoneGap apps to the new PhoneGap 3.5 and it's easier to create new, sample projects and just move the existing HTML/JS/CSS code over...)
During this work, I noticed that - with a few specific steps - the generated project can fire "deviceready" out of the box. Here are the details:
However, upon first launch of the project with Xcode, it doesn't seem to be noticed even though it's in the "Staging/www" view within Xcode. However, if you following procedure, the rebuild in Xcode seems to notice that it's there and package up the right bits to push to the device/emulator.
(Note, however, that the cordova.js file that appears in the initial creation of platforms/ios/www doesn't get removed. So, you end up with 2 copies of the same file with different names: cordova.js and phonegap.js)
With this approach, you don't have to edit the generated index.html solution (mentioned as another solution/workaround in this thread).
Upvotes: 1
Reputation: 438
Thanks to the suggestion by brauchle_andi above, I dug deeper and found the problem and just reproduced it in a 'clean' generated project.
I am using PhoneGap 3.5.0-0.20.4
I generated a new project (details) below and the file cordova.js is placed in the proper platforms/ios/www folder
However, the generated index.html has a reference to loading the script file, phonegap.js. Editing the index.html to load cordova.js fixes this problem.
Seems like a bug in the PhoneGap packaging process.
Here are the steps taken to reproduce this problem:
This creates the project with the problem described above. Editing index.html and re-running the project fixes it.
Upvotes: 0
Reputation: 320
well, im using 3.5.0-0.2.4 and it works like a charm.
perhaps you forget to inherit the cordova.js-file?
Upvotes: 1