When building your first PhoneGap (aka Cordova) project using XCode, there’s something to be aware of that could potentially cause confusion so I wanted to address it quickly with a post. First of all, to get started with PhoneGap and iOS, you can follow the detailed instructions here. This post is meant to supplement these instructions. If you are at the point where you have downloaded and installed PhoneGap (ran the PhoneGap-xx.dmg or Cordova-xx.dmg from the ios folder in the downloaded phonegap.zip etc) and opened XCode to create your first project, you will see a new option for Create a new Cordova-based Application (or Create a new PhoneGap-based Application depending on what version of PhoneGap you downloaded) such as below:
The trick is, once you select that option a project is created and opened just fine, but you MUST actually Run the application first to cause the special www folder (specific to PhoneGap projects and containing the main .js file PhoneGap needs to work) to be created in the same folder as the .xcodeproject file just created.
The instructions do mention executing the project and that you will get an error at that point, but don’t make it entirely clear that the important www folder will actually be created at that step. If you’re like me, you might decide to skip that instruction because you know it’s not going to work yet anyway since PhoneGap needs the www folder copied in. Yes, I can admit I did this the first time . Then you will probably try to follow the rest of the instructions to copy that www folder in and find that it’s not there. My personal assumption when I did this the first time is that the www folder was getting created for me when I selected the new Cordova-based Application option. Now that I have more experience, I can see how you may not ALWAYS want that www folder created upon project creation, such as the case where you are copying an existing one in, however I will have to follow-up more on this to see if there are changes coming in this workflow.
To illustrate, after creating your Cordova-based Application in XCode, if you right click on the root of the project in XCode and say Show in Finder, you will see this:
But after you actually Run the project in XCode and receive errors, then stop and right-click again on that root project in XCode to Show in Finder, you will the www folder was in fact created and is ready to copy in to XCode:
If you’re a developer that has run into this yourself (not one of those that always follows specific directions and never makes ANY assumptions ) then I hope this helped you quickly get to the bottom of it .
NOTE: This is specific to creating a brand new project, not porting over an existing www folder that already had the necessary contents where there is no need for a default one to be created.