My first iPhone Game - Step By Step


In October 2008, at a beer party with two my friends, I learned that they were both involved in developing games for the iPhone. At that time I already had almost finished shareware game for Windows.
Inspired to port it an iPhone, I started working in this direction.


Goal - Establish and configure the Windows platform toolchain without buying device and Mac. Mac and iOS device purchase was postponed until a full understanding how that works.
Almost finished project and tools for game development  were developed for Windows so i decided to do everything in Windows.
A few days for goggling and I started.
NOTE: Of course I bought Mac and iPod Touch later.

Step One  - Environment and toolchain setup for Cygwin

After a month of development and experiments, toolchain for Cygwin was done. As a result I have a huge makefile to build the toolchain and compiled HelloWorld application, which cannot be ran because I don't have device. When I say that it took a month, it does not mean that I worked a month for 8 hours per day, mostly the work was carried out on the weekends and after work. Much time was spent for recompilation, problems with paths and Win32-iOS functions mapping.

Step Two - Porting Win32 project to iPhone toolchain.

This step took a month of work. I first met with GCC, the command line, makefile, as a Windows programmer learned a lot. I would also highlith time spent for on refactoring for GCC and iPhone SDK. Much time was spent on troubles with header files and Win-Unix-iOS functions porting (some functions were absent on some platforms). Redesigning in a portable form through #define's and interfaceed was fairly painless, as well as reompilation Third Party libraries that I needed, such as Lua. A lot of time was saved beause original windows game used OpenGL and OpenAL. Both my friend warned me that there are many challenges when working with audio on the iPhone, in my case, OpenAL did his jobs without problems. I didn't touched my sound code at all. Also helped that engine core (each game programmer should have "pet engine") was tested under Embeded Visual Studio for the smartphone. During this period, programming and testing workflow was established. It is very easy to make changes in the Far or Visual Studio and check compilation for iPhone toolchain. Code always tested  on Windows. At some point, it decided to check code on Linux, Fedora Linux was installed for VirtualBox. I would like to note that the presence of Unit test will quickly identify and fix most problems (I could only run on Linux, but it was enough already). Also, I recommend to include the maximum compilation warning level and stop compiling if warnings appear (-Werror for GCC), and fix them all. Only this activity helped me fix several insidious bugs. Objective-C only used for startup and for UIController stuff. All other code in C++.
  • Game runs under Windows and compiled for the iPhone platform. Using "platform configs" I could run a game that worked almost like a on real device, including resolution, landscape orientation, the dimension of texture, etc.
Example of "platform config"
, This device
maxTextureSize = 256
touchInput = 1
hideArrowCursor = 1
fixedVideoResolution = 1
; Game under Windows in "compatibility mode"
maxTextureSize = 256
SupportNonPower2 = 0;
touchInput = 1
# HideArrowCursor = 1 //  cursor visible
fixedVideoResolution = 1
  • Windows version (very old interface)

  • Toolchain for iPhone. Then, quite unexpectedly, I found CygwinPutty - PuTTy modification for Cygwin.

Step Three - Hardware and testing

To test the functionality for real hardware iPod Touch 3g 8GB was bought (as i decided later 8gb iPod Touch 3g actually 2g). Jailbreak was done, and ... everything started without problems from first time. A few lines were added to makefile to upload it to device. Command line scp was used to upload on the device. To bypass password asking for every connect authentication was changed to ssh keys.

Step Four - Optimization and debugging

Almost from start i understand that CPU on my iPod Touch 2g cannot handle physics in real time, actually in that time i almost did deision about canceling this project. On big scenes physics, simulation can take up to 300 ms per frame, it is unacceptable. As a final result physics was separated from rendering. Rendering with maximum FPS if physics not started and limited to 10 FPS if physics simulation started. Physics simulation starts immediately after player pressed Start button. So when you see "count done" and hear siren sound physics already simulated for a 2..3 seconds. Of course physics parameters were re tweaked to pass 100ms per frame restriction, as a result a little slow was introduced (By the way i like that slow more - it allows detect trajectories of blocks which goes outside fence), so for better hardware this slow mo still be available, from now this is game play feature. So minimal hardware spec was established as my iPod 2G. After a few experiments  -O3 optimization level was chosen. Also 3d rendering was optimized: DIP count decreased, VBO, almost all DIP's with alpha test was removed, OpenGL state proxy was implemented. Debugging via logs files and gdb installed on my device. Code was tested very good for windows platform so i did not get any troubles with iOS. Memory leaks were fixed on windows using Visual Leak Detector. All possible problems with OpenGL was fixed or detected via geDebugger.

Step five - MacOS and xCode

To release game in AppStore you need MacOS, xCode and developer certificate. MaOS 10.6.5 and xCode was installed to Virtual Box.
A few days was spent to compile for iPhone simulator.
Investigation phase was finshed.

Step Six - Developer Certificate
To compile for real device using xCode you need to be in “iOS Developer Program” - 99$ per year. Bank account was opened and strted registering process for “iOS Developer Program”.
First trouble i get when i did not found my country in Apple registration form. (Ukraine).

Apple please add Ukraine to countries list!!! Here almost 38 millions of people!!! Almost all my friends had device based on iOS!!
I think install base in Ukraine bigger then in most European countries.
Ukraine is another country where you can beat Nokia.

So they asking to fill registration form,fill credit card info, print it and send this document by fax.
  • 28 January 2011 - Registration Form filled and sent via PamFax
  • 2 Febrary 2011 - I got answer. From that time i am iOS Developer!!!

Step Seven - Mac Mini

Mac mini was bought. That's solved my last problems.
  • Compilation performane was very slow with virtual pc
  • Investigation phase was finished
  • Legalization
Main development fully on Windows. Toolchain to check compilation for iOS. Actually i want to setup autocompilation daemon to check every submit.
By the way i did not install any cracked application - I value your work. All my friends think in the same manner.

Step Eight - Lite Version

Game is not casual so i decided release Lite version first. In my future article i will analyze and $ummarize this.
  •     1 June 2011 - "Waiting for Review"
  •     8 June 2011 - Ready for Sale

Step Nine - Implementing feedback from Lite version

Feedbacks from Lite version and my friends figured on that some my decisions in the user interface were not as intuitive as I thought.

On picture old and new main menu
Button Play (small button with arrow on bottom right) obviously was not clear to the players, many people simply do not guess press it. Solution - click on the level icon starts the level - Play button was removed. Buttons to change pages  were replaced to simple arrows.

Implementation details

GameCenter integration

GKTapper example was used as a base. I didn't get any problems with it.
GameCenterMenager.h and GameCenterMenager.м come in to my code without changes.

OpenFeint integration

I stalled for a one day with one problem. OpenFeint dashboard was unvisible by some reasons. RTFM and I fixed it. Actually I fotgot hide my view controller before show OpenFeint dashboard
- (void)dashboardWillAppear
- (void)dashboardDidDisappear

Facebook integration

I did it like was described in
Big problem appeared because of OpenFeint already used some old facebook SDK and i got linker conflicts. My solution was very simple I added defines similar to "#define FBDialog MFBDialog" to rename my Facebbok SDK classes.
Also i got a problem with Facebook post dialog - he always displayed captha before post to wall in case if your images is outside domain.

Twitter integration

MGTwitter was used. This engine does not have preview dialog for posting.
ViewController with buttons "Post" and "Skip" was implemented.
Based on UIWebView. Post and Skip buttons events was catched and redirected to MGTwitter.
My source code -

Rate Me integration

iRate was used.
For lite version i put 7 days and 7 runs.
For full 20 days and 20 runs.

Multi touch

For multi touch debugging i wrote simple server for device. Windows game on start connects to the device and getting all touches from device events by network.

Version control

SVN for code and data. On Mac pc source code taken from Windows shared folder via network. While i work alone with code this is not a problem.


  •     iPod Touch 2g 8GB - 270$
  •     iOS developer - 100$
  •     MacMini - 800$
  •     My spare time


What's went good

  • Main development on Windows. Ability to run and test as well as reload assets by pressing "R" button saved me a lot of time. My expirience with Visual Studio 10 years, i have no time to learn xCode.
  • Very easy to catch gameplay video YouTube Video
  • Targets  - this is one of my many project whch was finished. Almost all my home projects were frozen. For that project i have very strong target to finish it

What's went bad

  • Art - i did it myself and you can see the results.
  • Interface  - originally came from Windows game and was too complicated, for iPhone i left only 1 screen.
  • Playtests - i did it myself. In most cases i did not saw any problems which was visible for other people
  • Work time  - work in such pace is impossible for a long period