From HTML5 to iOS native game with PhoneGap – step by step guide

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.

First, you will need Node.js. Node.js is an open source, cross-platform runtime environment for server-side and networking applications. So go to Node.js site and install it.

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:

cd ninJump

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.

Get the most popular Phaser 3 book

Through 202 pages, 32 source code examples and an Android Studio project you will learn how to build cross platform HTML5 games and create a complete game along the way.

Get the book

214 GAME PROTOTYPES EXPLAINED WITH SOURCE CODE
// 1+2=3
// 100 rounds
// 10000000
// 2 Cars
// 2048
// A Blocky Christmas
// A Jumping Block
// A Life of Logic
// Angry Birds
// Angry Birds Space
// Artillery
// Astro-PANIC!
// Avoider
// Back to Square One
// Ball Game
// Ball vs Ball
// Ball: Revamped
// Balloon Invasion
// BallPusher
// Ballz
// Bar Balance
// Bejeweled
// Biggification
// Block it
// Blockage
// Bloons
// Boids
// Bombuzal
// Boom Dots
// Bouncing Ball
// Bouncing Ball 2
// Bouncy Light
// BoxHead
// Breakout
// Bricks
// Bubble Chaos
// Bubbles 2
// Card Game
// Castle Ramble
// Chronotron
// Circle Chain
// Circle Path
// Circle Race
// Circular endless runner
// Cirplosion
// CLOCKS - The Game
// Color Hit
// Color Jump
// ColorFill
// Columns
// Concentration
// Crossy Road
// Crush the Castle
// Cube Jump
// CubesOut
// Dash N Blast
// Dashy Panda
// Deflection
// Diamond Digger Saga
// Don't touch the spikes
// Dots
// Down The Mountain
// Drag and Match
// Draw Game
// Drop Wizard
// DROP'd
// Dudeski
// Dungeon Raid
// Educational Game
// Elasticity
// Endless Runner
// Erase Box
// Eskiv
// Farm Heroes Saga
// Filler
// Flappy Bird
// Fling
// Flipping Legend
// Floaty Light
// Fuse Ballz
// GearTaker
// Gem Sweeper
// Globe
// Goat Rider
// Gold Miner
// Grindstone
// GuessNext
// Helicopter
// Hero Emblems
// Hero Slide
// Hexagonal Tiles
// HookPod
// Hop Hop Hop Underwater
// Horizontal Endless Runner
// Hundreds
// Hungry Hero
// Hurry it's Christmas
// InkTd
// Iromeku
// Jet Set Willy
// Jigsaw Game
// Knife Hit
// Knightfall
// Legends of Runeterra
// Lep's World
// Line Rider
// Lumines
// Magick
// MagOrMin
// Mass Attack
// Math Game
// Maze
// Meeblings
// Memdot
// Metro Siberia Underground
// Mike Dangers
// Mikey Hooks
// Nano War
// Nodes
// o:anquan
// One Button Game
// One Tap RPG
// Ononmin
// Pacco
// Perfect Square!
// Perfectionism
// Phyballs
// Pixel Purge
// PixelField
// Planet Revenge
// Plants Vs Zombies
// Platform
// Platform game
// Plus+Plus
// Pocket Snap
// Poker
// Pool
// Pop the Lock
// Pop to Save
// Poux
// Pudi
// Pumpkin Story
// Puppet Bird
// Pyramids of Ra
// qomp
// Quick Switch
// Racing
// Radical
// Rebuild Chile
// Renju
// Rise Above
// Risky Road
// Roguelike
// Roly Poly
// Run Around
// Rush Hour
// SameGame
// SamePhysics
// Save the Totem
// Security
// Serious Scramblers
// Shrink it
// Sling
// Slingy
// Snowflakes
// Sokoban
// Space Checkers
// Space is Key
// Spellfall
// Spinny Gun
// Splitter
// Spring Ninja
// Sproing
// Stabilize!
// Stack
// Stick Hero
// String Avoider
// Stringy
// Sudoku
// Super Mario Bros
// Surfingers
// Survival Horror
// Talesworth Adventure
// Tetris
// The Impossible Line
// The Moops - Combos of Joy
// The Next Arrow
// Threes
// Tic Tac Toe
// Timberman
// Tiny Wings
// Tipsy Tower
// Toony
// Totem Destroyer
// Tower Defense
// Trick Shot
// Tunnelball
// Turn
// Turnellio
// TwinSpin
// vvvvvv
// Warp Shift
// Way of an Idea
// Whack a Creep
// Wheel of Fortune
// Where's my Water
// Wish Upon a Star
// Word Game
// Wordle
// Worms
// Yanga
// Yeah Bunny
// Zhed
// zNumbers