How to port an iPad app to Mac? - iphone

I know it's not easy. Is there a step-by-step guide for iOS developer to climb the Mac OS learning curve?
Besides, IconFactory is working on the chameleon project. How much effort will be saved comparing to a traditional port?

It's a similar learning curve to learning iOS SDK development, minus the stuff that's the same: tools, cocoa conventions, Foundation objects (NSString NSArray etc), Core Graphics & Core Animation (mostly), and other lower level frameworks that are similar in both. Basically everything in your app that uses UI<something> needs to be rewritten in something similar but different. In many apps that's a big percentage. I myself eagerly await this "cha-me-leon" project (yes, that's a HIMYM reference).

Related

Where can I find a tutorial for building a simple OpenGL app for an iPhone newbie?

I'd like to get into iPhone development (mainly OpenGL & games stuff, no GUI apps). Got 10+ years experience of thorough Windows development, mostly C++ / win32 api, some OpenGL. However I have absolutely NO experience with Mac or Apple whatsoever.
I'm confident I'll pick up the concepts without any trouble, but I got no clue where to begin, or even how to setup an iPhone development environment. Should I use GCC? or Xcode (is that an IDE and/or compiler?) and is there a step-by-step introduction somewhere to create an initial project?
There's an overkill of info and tutorials out there, but they all seem to assume some initial Mac development knowledge which I don't have. An absolute newbie tutorial on creating an OpenGL "hello world" for iPhone step by step from scratch would be awesome.
Does anyone what would be a good place to start for me?
1 -- The example projects in XCode on the Mac make excellent starting points. XCode is an IDE... and if you set the target to "simulator" it just pops up the iPhone simulator. Fire it up, you can't miss it. Download from developer.apple.com.
2 -- I really liked the book "The iPhone Developer's Cookbook: Building Applications with the iPhone SDK"
3 -- Objective C is kinda quirky but you get used to it quickly enough, plenty of web resources and books are easy to find.
I would also take a look at Stanford University's free iTunes U course in iPhone development. It's a great, thorough explanation of the iPhone platform and Objective-C. There's a "Hello World" tutorial in there, but the videos go much farther and will give you a good deep dive into the ecosystem. There is an OpenGL ES section as well.
If you haven't done so yet, you will need to either buy a Mac or build a Hackintosh, since you have to have OSX for development.
I did a test OpenGL app last fall, and found the best book for 3D on the iPhone was:
iPhone 3D Programming
By: Philip Rideout
It covers both versions of OpenGL ES that you need to be aware of if you want your apps to run on older iphone hardware, although if you only want to target the 3GS and up (and 3gen ipod touch, and ipads) then you can skip to OpenGL ES 2.
It has complete examples, a good explanation, and best of all it recognizes that a lot of people coming to the iPhone for games development already know C++, and it focuses on getting you right into the C++ OpenGL rendering loop. You have to deal with very little objective C, and most of that is well explained with examples that are easy to use.
It doesn't cover game design - it's just to get you going in 3D on iOS, so if you aren't familiar with OpenGL and game design fundamentals you should also invest in one of the many game design and opengl bibles that are available.
As far as programming the iPhone on windows, it's possible, and I have a friend doing it using a hackintosh VM. I decided to just get a cheap mac mini I found on sale when the new ones came out a few years ago. My friend found that his setup worked well enough to get to the stage where he was willing to commit to his app, then he invested money and bought a mac mini. He indicated that development just flies now, compared to his VM, and he wishes he switched sooner.
Whether you have the $500+ to invest in it is up to you, but be aware that there really aren't any other good options for iOS development yet, and you cannot easily submit apps to the apple store without a mac and xcode, so if you plan on going that route, you need to budget for a mac.
For the simplest development environment for someone starting out with iPhone development, you'll want to go with a Mac running Snow Leopard and use Xcode with the iPhone SDK. Xcode is an IDE that contains within it a modified version of the GCC (or LLVM) compiler targeted at producing Mac or iOS binaries. It also includes a full iOS simulator for quickly testing out your applications.
There are ways of doing iPhone development on Windows, but they are extremely difficult to get set up and ultimately more of a curiosity than a practical means of development
There are a good number of getting started resources listed in this question. I recommend the Stanford videos, as well as Apple's getting started videos that you can access through the iOS Dev Center. Apple also has an iOS Getting Started document that acts as a jumping-off point for their other introductory documentation.
Be aware that OpenGL ES is not a simple subject to just jump into. You can easily create an OpenGL ES "Hello World" application by opening Xcode and creating a new project from the OpenGL ES Application template, but you'll have a hard time figuring out what to do after that. However, OpenGL ES is something you can learn independently of Cocoa and Objective-C, so if you want to jump into that topic, I taught a class on the subject which can be found on iTunes U as part of my advanced iOS development course. I walk through the fundamentals of OpenGL ES 1.1 there (2.0 can be found in the fall semester of the course). I also highly recommend Philip Rideout's iPhone 3D Programming book and Jeff LaMarche's series on the topic.
Don't let the initial complexity of OpenGL ES scare you away. You should be able to pick up the basics reasonably quickly if you apply yourself.

Is iphone development very similar to Mac OS X development?

I'm learning (watching videos) on iphone development, and I am curious if this knowledge can be transfered to creating regular Mac OS X desktop applications?
i.e. is it MVC based also? is allot of the framework carried over also?
Just a little confused between cocoa, iOS and if they overlap.
P.S what is the shortcut keys to launch an iphone app? I can't figure out what that wierd symbol is.
In essence "yes". However, taking each of your questions in turn:
Whilst there's no UIKit classes on Mac OS X, the general development approach (and indeed a lot of the pure Cocoa class specifics) are identical. The run loop/event based nature of both systems are also effectively identical from a programming perspective.
As such, time spent learning the iOS way of doing things will pay off if you go on to develop Mac OS X applications, as you'll know parts of the Cocoa framework and what you've learnt of the UIKit bits and pieces will transfer across to the Mac OS X's NSxxx equivalents.
iOS and Mac OS X Cocoa development are both MVC, although it really depends on the programmer to keep things "pure".
In terms of launching an iPhone app, I've no idea what you're talking about, but at a guess, the "weird" symbol could be the command (a.k.a.: "clover") key that's a standard part of all Mac keyboards. (A bit like the Windows key on Windows keyboards these days.)
Incidentally, there's some general Cocoa/Cocoa Touch information over on the Apple site, although this is fairly high level.
iOS is the operating system (including the kernel, OS services, and the UI). Cocoa and Cocoa Touch are mostly the UI layer libraries or frameworks.
Mac OS uses the Cocoa UI frameworks. iPhoneOS/iOS uses Cocoa Touch UI framework. Both use (nearly) the same Objective C language and the same Foundation classes.
However, though the UI frameworks are similar in concept, they are not identical in terms of classes or "gotcha's". So you will have to rewrite pretty much all the UI code of an app, but using a fairly parallel MVC style.
You will also need to learn how to do manual memory management in Cocoa Touch if you are used to taking advantage of the garbage collection enabled implementation of Obj C 2.0.
But if you know one framework, you will be able to pick up the other much more quickly than starting from scratch.
For the record, Todd Ditchendorf has been developing UMEKit, a Mac OS X framework for creating iPhone-like user interfaces in Cocoa desktop applications.

Does it make sense to first learn Cocoa for Leopard and then Cocoa Touch for iPhone?

Actually I don't care too much about Mac OS X development. I want to do only iPod Touch and iPhone development. But anyways, I started learning Cocoa and Objective-C. But it seems like there are many differences between Cocoa and Cocoa Touch, so I am wondering if I am actually wasting my time. Should I just jump directly into iPhone topics?
There is lots of overlap, but if your purpose in learning is to do iPhone programming, then by all means learn iPhone programming directly.
As a side-effect, you will be able to pick up Mac application programming more easily if you should ever have such a desire.
I think you could go either Cocoa-Cocoa Touch or Cocoa Touch-Cocoa and still have a good grasp on what it takes to program for either platform. I tried Cocoa development on my Mac a few years ago and was pretty confused. I finally decided to take up iPhone programming, and picked up Beginning iPhone Development: Exploring the iPhone SDK, worked through that book over a few weeks, and I understand things much, much better now. Really, all it takes is a good explanation of Mac programming. I'm fairly confident I could pick up regular Cocoa programming with far less effort now. Had I started with regular Cocoa programming, I'm fairly confident I would have been able to pick up iPhone programming fairly easily. There are differences, but there are a lot of (very cool) similarities between the two platforms.
PS, I highly, highly recommend that book if you're really interested in iPhone development. It was worth every penny.
Normally I would agree with the other answers here: directly learn the topic you're interested in. But in the case of Cocoa/Cocoa Touch, you'd be better off reading Cocoa Programming for Mac OS X, 3rd ed. by Aaron Hillegass. It's just that damn good!
There are similarities but if the goal is iPhone development, you'll be much better off starting to learn on that platform and then stepping up to the Mac. There's a lot more going on both in the UI frameworks, and in terms of what IB can do so you may well get used to some aspect of the system that is not present on the iPhone (or done differently).
The NS foundation classes are much the same but even there are differences.
Also beware that the simulator will compile and run Mac code that will not compile or run on the phone itself, when using the docs always keep them focused on the iPhone SDK section.
One difference between Cocoa Touch and Cocoa is in the area of memory management.
If you happen to be learning Objective-C for the very first time (or possibly any C-based language for the very first time) I would start with Cocoa Touch.
My reasoning is that the iPhone does not support automatic garbage collection, and you may find it easier to learn the (more difficult? certainly less automatic) way first, then as you migrate to OS X development appreciate the shortcuts that the OS X platform gives you.
If you learn Cocoa development on Leopard initially, you may be frustrated at the seemingly more primitive memory management available in the iPhone.
The two are very similar, though.
Bottom line is if you want to learn to program for the iPhone, go ahead and jump to the iPhone. Mac OS X development is not a prerequisite, just a very similar skillset.
I've taught Mac developers and iPhone developers, and my experience is that it's generally best to learn Mac first, particularly because you can get a solid grounding in Cocoa using Cocoa Programming for Mac OS X, which is still the best book on learning the Cocoa patterns around. So far I haven't found a good iPhone book that teaches the key issues you need to know, and that differentiate Cocoa/Touch programming from Java, .NET and other systems. I've written a couple of articles recently that may be helpful as you think about this:
iPhone Course Syllabus
Review of iPhone Developer’s Cookbook
I've went through about the same question as you, though my initial focus was more on Mac development, the iPhone came later. I'm by no means an expert cocoa coder yet, but things are improving rapidly. I find that the things I learned about cocoa on the Mac come in quite handy on the iPhone; picking up iPhone development certainly went a lot quicker than my first steps in cocoa on the Mac...
In practice, I find both skills come in handy. I'm making an iPhone game, but the data set it uses (the actual puzzles) are created using a small cocoa app I've developed for the Mac. Is there a specific reason why you don't want to learn Mac development? You don't need additional development/designing tools for your game?
(screenshot of the mac app: http://www.qixis.com/images/edit16-screenshot.png)

Is it better to start how to code in Objective-C for the desktop before you venture to the iPhone?

I have C/C++ experience so learning Objective-C is not completely foreign to me. However, I noticed that writing an application for the iPhone is not as simple as for the desktop platform. Should I start to get some solid experience on the desktop before I jump into the iPhone? I am not a commercial developer, and merely doing this as a hobby and for learning purposes. What is your recommendation?
For what it's worth, a comment from another newcomer to iPhone development...
My background - I was a C Programmer about 15 years ago and since then I've moved around technologies quite a bit - I'm now an Adobe Flex developer in my day job. By night, however, I'm trying to transform myself into an iPhone developer ;-)
So I bought a book on iPhone SDK development - 'iPhone in Action'. I also bought 'Programming in Objective-C 2.0'. I thought I'd be set with these two but after a couple of days reading and working through exercises it was clear that... I was hopelessly lost!
So I bought another book - this time, 'iPhone SDK Development' from the Pragmatic Bookstore - this is a work in progress book but looked 'right' for me. Turns out this book took me further - it's a great piece of work - however, the early chapters were paced nicely and I was able to follow along and then all of a sudden they began to assume I could recall perfectly the lessons learnt and the procedures followed in earlier chapters and I began yet again to flounder a little - the worst thing I find when trying to learn something from a book is to have to jump around from place to place constantly to make any sense of what I'm meant to be doing.
So (yeah, I know... but bear with me...) I bought ANOTHER book... 'Beginning iPhone Development' from APress. Now THIS book assumes nothing. For a beginner to iPhone development, THIS book hits the target. No jumping around necessary and finally I found I was progressing.
However, what I'm finding is that ALL three books in CONJUNCTION with one another really seem to provide me with a more complete picture - collectively I have a great set of tutorial and reference material. The Objective-C book I've not touched on so much yet but I expect that to be what I need it to be - a reference manual for the language; I'll not need that until I'm much deeper in to the guts. I'm slowly emerging from that horrible "in at the deep end and I can't swim very well" feeling to one where I can at least tread water. Hopefully with a bit more paddling I'll be able to touch the bottom - certainly my confidence is returning ;-)
So anyway, to address the original question - personally if I did this all over again, I don't think I would have gained anything by starting out building for the Mac first and then to the iPhone. I would definitely have lost less hair had I bought the APress book first - that for me was the book that made complete sense of everything for me. I think then the 'iPhone SDK Development' Pragmatic book was the best backup/followup book. This is the path I've suggested to a colleague and I'm confident it's a good one.
Hope this helps!
Jamie.
It is definitely helpful to have some Cocoa experience before going into iPhone development, but I personally wouldn't sweat it that much. Learning how to use the Cocoa framework and getting comfortable with it in general would be beneficial, but there are certain aspects of desktop Cocoa programming that you will find have little relevance to iPhone programming (e.g. user interface design with Interface Builder). Also, there are unique aspects of iPhone programming that normal Cocoa programming won't really prepare you for. (Some experienced Cocoa devs still had somewhat of a learning curve when they first got into iPhone development.)
In other words, I would recommend learning the fundamentals of normal Cocoa development, but you won't need to become a Cocoa guru in order to learn how to develop iPhone apps.
If your only intend in coding desktop apps is to get familiar with Objective-C, cocoa and Xcode, it is not worth.
You will learn nothing starting with desktop apps that you would not learn getting straight in iPhone apps. Desktop apps are not simpler than iPhone apps, they are just different.
It may even be counter productive if you learn specificities of desktop apps that you will have to 'unlearn' on iPhone development.
Of course, if your intend is to get into the OS X ecosystem, learning both would be very valuable.
In some ways the iPhone is simpler for a C/C++ developer. No garbage collection is the big one. If you start on the desktop and get used to GC, you'll have a hell of a time when you hit the iPhone.
There is no need to or benefit in learning desktop Cocoa before moving to UiKit on the iPhone. There may be some disadvantages.
Although there are a lot of concepts shared between UIkit and Cocoa they are no easier to learn on the desktop. And at the end of the day, they are not identical. Similarly there are a lot of frameworks that are shared between iPhone and the desktop - in these cases, there is nothing to be gained from using the desktop versions before their equivalents on the phone.
There some difficulties that you will face only on the iPhone and things that might make things easier on the desktop:
you develop on the target machine, on iPhone, target management is more difficult
iPhone is memory and processor contstrained
there is no Garbage collection on iPhone
My view is that it is a good idea to get used to these issues as soon as possible rather than getting into "bad habits" on the desktop (or just generating misunderstanding when you go to iPhone).
If you have any development experience you know that all languages are alike, and you only know if you fully grok it only by working with it.
My approach to learning a new development environment is to pick a problem you want to solve (and since the phone is in your pocket all the time, you're likely to have some idea), and bang your head on it.
There's a ton of apple sample code, answers here and on other sites. Start with a working sample app that is not too far from what you want to do, and tweak it over time. You are gratified by a working app, find out about problems right away, and can learn small bits at a time.
The biggest challenge is not learning Cocoa and/or Cocoa Touch but Objective-C. Once you have the fundamentals Cocoa is simple and similar to many other OO frameworks.
I suggest:
The Wikipedia article on Objective-C: https://en.wikipedia.org/wiki/Objective-C
"External links" at Wikipedia for some fundamentals of the language
Hot Cocoa podcast: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=294050835
Cocoa Cast podcast: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=298413458
Then the Stanford iPhone Application Programming course on iTunes U: https://podcasts.apple.com/us/podcast/iphone-application-programming-spring-2009/id384233222
Join the developer program at Apple: https://developer.apple.com

Going from the iPhone to the Mac?

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.
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.
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.
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.