tags:

views:

175

answers:

3

Note: This is the opposite direction to most similar questions!

I have an iPhone application which I would like to provide a demo of on the Mac. How hard is it to recompile (or rewrite) iPhone applications into Mac applications, assuming I intend to keep the same screen size, and not worry about making my application look "mac-like"?

Is it possible to distribute the iPhone simulator apple provides in the iPhone SDK with a copy of my application? Asking people to go and install it themselves seems like a major requirement.

+4  A: 

First, you can't distribute the iPhone simulator. That's out of the question. The iPhone SDK agreement states:

You agree not to rent, lease, lend, upload to or host on any website or server, sell, redistribute, or sublicense the SDK, in whole or in part, or to enable others to do so.

You might be able to use parts of your program in the Mac version, but you'll probably have to rewrite UI-related code.

Can Berk Güder
+2  A: 

If your app is mostly OpenGL or custom views, probably not too hard at all. If your app using lots of UIKit views, then you will need to rewrite quite a bit to use the Mac standard Cocoa views instead. They are quite different.

Squeegy
+5  A: 

On the whole most of the "core" frameworks are present on the Mac too. As a rule of thimb, any class starting NS will be present on the desktop - NSString, NSArray and NSObject etc. That hopefully means that all of your engine code will simply recompile and run.

The same is true of some middleware - all of iPhone Quartz will be present - classes and types starting CG... If you use 3D, there is OpenGL on the desktop but it is full OpenGL rather than the iPhone's OpenGL ES. There are some differences but your code will be pretty easy to port.

Where you will definitely need to recode is the UI. Not only because AppKit is not present but because the UI design you need for iPhone will generally not work on the desktop. The iPhone supports multitouch and does not have (meaningful) overlapping windows. Similarly, if you use any of the iPhone's hardware you will have to reimplement - the accelerometer and GPS are obviously not available on the desktop. In both these cases, the rule of thumb is that classes starting UI... are specific to the iPhone.

If you follow Apple's MVC design guidelines when you write your app, if will keep the UI related code well seperated from the engine code and porting should be easier.

Roger Nolan