2

I have used cocos2d c++ to create a small game on my Windows machine. It looks great and now I am planning to put it on my iPod Touch. Can anyone tell me how can I achieve this without actually porting my app on objective c?

I have MAC machine and I can arrange for Apple Developer license as well.

Please help me in this.

Hiren
  • 341
  • 1
  • 4
  • 17
  • C++ is not officially supported by Apple's modified version of GCC for the iPhone/iPad. But there are hacks out there to compile C++ code to the iOS but I haven't seen a complex projects with external dependencies/libraries. These hacks involve installing a GNU toolchain on the device itself and compile the code your project there. This means you won't be using your Mac to compile the application and you'll have to install and compile every dependency your game has on the device before being able to compile your code there. – karlphillip May 09 '11 at 19:07

1 Answers1

2

A few years ago, Joel asked the same thing. There are very interesting comments there, you should take a look. This one is very enlightening:

Google "Objective-C++". That will give you ideas how to allow your C++ to interface with Objective-C APIs.

After a quick search on stackoverflow, I found that at that time, someone else asked the same question here: Is it possible to program iPhone in C++

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • @karlphilip I read Joel's blog before posting the question.I have a game done using cocos2d-x and now I want to port it on iPod touch or iphone. – Hiren May 09 '11 at 16:48
  • It's not clear to me what is holding you down, since Cocos2D-X is a port of the Cocos2D-iPhone game engine using C++. So please forgive me for asking this, but have you ever written an application for the iphone/ipad? Because it doesn't really sound like a technology related problem but rather a *I-don't-know-how-to-get-started* type of problem. – karlphillip May 09 '11 at 17:04
  • @karlphilip I have not written iPhone app before but i used cocos2d-x to develop my game in windows environment and now I want to port it on my iPod Touch.I have MAC machine but I really don't want to re-write my game in Objective C on MAC so how can I use same code base in order to run my game on iPhone? – Hiren May 09 '11 at 18:38
  • Before trying anything fancy like that on the iPod since you never coded to the iOS before, I suggest you try something simpler like a `hello world` application for the iPhone, written in C++. This will introduce you to the basics of compiling C++ code and running it on the device. – karlphillip May 09 '11 at 18:42
  • @karlphilip I have done that before I started writing my game.Anyways maybe I am not able to explain you my problem or something else but this conversation is not leading me anywhere :( Thanks a lot for your valuable time. – Hiren May 09 '11 at 18:46
  • 1
    The iPad can be seen as a computer just like any other computer you've met. It's just that it requires a specific set of tools to compile your code into a binary that can be executed inside the device. Check this page: http://jeremylg.blogspot.com/ – karlphillip May 09 '11 at 18:55
  • There are other tutorials, like: http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884 – karlphillip May 09 '11 at 18:58