Once you create an HTML5 game, you will want to publish it to App Store too, just to have one more revenue stream. Today I am going to show you how to easily convert your HTML5 game into a native iOS game using PhoneGap.
I already showed you how to use the PhoneGap Cloud Service to make PhoneGap do all the dirty job, but you will have more control if you install PhoneGap on your computer.
Also, PhoneGap Cloud Service is free only for one non open-source project.
Bad news are you must have a Mac. But if you’re serious into iOS development, I am sure you have one.
This is what you should get once Node.js has been installed
Time to open the Terminal and enter:
sudo npm install -g phonegap
This will install PhoneGap on your Mac.
This will take a while, and when the process is finished and you have PhoneGap installed, it’s time to create your first project.
enter on Terminal:
phonegap create ninJump com.emanueleferonato.ninjump ninJump -d
This command should be customized, and simply means to create a project called “ninJump” with id “com.emanueleferonato.ninjump” – have a look at the reverse domain name – in a folder called “ninJump”. Obviously my game is called “ninJump”, name your project as you want.
Once the project has been created, move into the folder with – in my case – this command:
Then have a look at which platforms can you target using
phonegap platforms ls
If you have Xcode correctly installed on your Mac, you should see “ios” in the list of available platforms.
It’s time to build the game! Enter
phonegap build ios
and you will have your HTML5 game turned into a Xcode project
In the “ios” folder inside “platforms” folder inside your project folder you will find the xCode project. Launch it.
Once inside your Xcode project, select a device from the ones supported by the simulator – in this case an iPhone 5 – and launch the game with Product->Run and you should see the default project created by PhoneGap running on the device simulator.
To make PhoneGap work with your actual project, simply copy your game files in the “www” folder once you created the project. All in all the whole PhoneGap Xcode project is onyl some kind of wrapper, so you can do anything you want with the “www” folder.
This time I forced the game to run in landscapemode, also hiding the status bar.
And here is my game running in the simulator.
Next time I will show you how to add ads and export the game on an actual device.