Sunday, June 21, 2009

Porting Ren'Py to iPhone project

Ren'Py is a visual novel framework written in C and Python which conveniently compiles Win32, OS X and Linux targets for you. For those of you old enough to remember "Choose Your Own Adventure" books, visual novels are basically the same idea.

One platform Ren'Py does not support is iPhone, likely due to these factors:

  1. The Ren'Py developer community's doubts about the viability of the iPhone app economy (commercial visual novels cost more than most iPhone apps) compounded by recent dustups concerning App Store authors not being paid in a timely fashion
  2. Apple's public stance against App Store apps with code interpreters. Under the terms of clause 3.3.2 of the iPhone 3.0 SDK, it would seem to be impossible to develop any kind of software with a code interpreter that uses its own frameworks. And yet this is being debated endlessly across forums ever since the 3.0 SDK came out. I suspect the more hardline Apple tries to be on this point, the harder developers will push to create better toolchains of their own, leaving Apple in the unenviable position of trying to add EULA language prohibiting you the end user from choosing what kind of software you want to run on a device you outright own (they had the choice not to port the iPhone to the iPod Touch).
Despite these obstacles, we have to remember that the iPhone platform was designed for a very specific purpose: to waste as much time as humanly possible. And to this end, visual novels are IMO a killer pocket app.
Just to make it all fun, I have zero experience with Python or XCode and limited experience with C-based languages -- but then, most of my learning new stuff has been to build real-world projects.
So, let's enumerate what has to be done to accomplish this particular project:

Goalposts:

  • Learn Ren'Py/Python
  • Learn SDL framework
  • Learn enough Objective-C/C++
  • Learn enough iPhone dev process/XCode/alternate toolchains

Ren'Py main dependencies:

  • PyGame
    • Python (found, available from Cydia)
    • libsdl (found)
    • ffmpeg (proven, on Cydia)
    • libogg (proven, on Cydia)

Possible final product distribution:

  1. unjailbroken app distributed via ad hoc (ad hoc is limited to 100 users)
  2. jailbroken app distributed via Cydia
  3. self-distributed manually installed .ipa package (potential path, not enjoyable yet for end users)

Possible packaging:

  1. Standalone package (possibly a compile option for Ren'Py main)
  2. Shell app to be fed game files from existing games (i.e. jailbroken app)

Issues/obstacles:

  • Licensing for Python / SDL incompatible with AppStore (irrelevant) and not necessarily free for commercial products
  • This suggests a shell app feature which can load Ren'Py /game
  • Performance hits from multiple software abstraction layers and interpreters (could be serious)

Recently discovered resource:

haXe for iPhone (iPhone port takes care of SDL wrapper, among other things)

6.28: found libsdl for iPhone
6.29: iPhone 3.0 SDK installed
6.30: Looking into open source toolchains to bypass iPhone 3.0 SDK licensing issues