IPhone and iPad - how do I unlock a code?

My question is this: I have an application designed for the iPhone, and I decided to develop the code, in other words, I will develop two versions of the application at this initial stage: one for the iPhone and the other for the iPad.

My question is this: how do I develop code? I would like to continue using one project for both versions, but obviously I will have to write sections of code for the iPhone and other sections exclusively for the iPad and, of course, have many common parts for both releases.

How can I do this without messing up the code?

What are the best practices? Thanks for any help.

+6
iphone ipad
source share
4 answers

The problem with multiple goals is that it can conflict with the distribution model.

From what I understand, iPad and iPhone apps will be distributed as a single binary. The application decides whether to show the user interface of the iPad or iPod at runtime.

This means that if you do not want to separate applications from the "Foo" and "Foo iPad Edition" stores, you cannot use several goals and somehow you will have to work with one code base.

I hate this because there can be many conditional things in the application. If the iPad does this, otherwise do it. If the iPhone displays this controller, otherwise display a different one. I do not think this will lead to good code.

So, at the moment I’m thinking of doing something in the middle: I will create basically two code bases and somewhere at the very beginning of the application, I will decide to switch to the full iPad or iPhone code.

+2
source share

You can configure the Xcode project to use several purposes, then you can assign some source code file for one purpose or for another or for both

+3
source share

I'm not an iPhone developer, but from what St3fan points out (that it should be distributed as a single binary), this seems like a classic case for a factory pattern. Any other thing is implemented in two different ways (with a common interface), and the factory uses a different implementation based on if it is on an iPhone or iPad. The general code does not need to be changed, so it can remain as it is.

+1
source share

I answer your questions: 1) "how do I do this task" you have to create a new goal from the project menu in my case I use two different goals for playing on the iPhone (regular and free (lite) version)

so I created a second Target of Type Application this will add a Target to the Groups & Files panel and will create a new Info.plist file in the Group&File you can show more columns (by right clicking) on "Group&Files"), here you have to show the "Target Memebership column" for each file you can decide if it is part of a target by pressing the corresponding check box 

2) "what about code parts" I don’t know if the current Beta SDK for developing iPad applications contains some #define that you could test at compile time in each case, you can set a specific highlighted #define at the target level and check this to do some conditional compilation

you can find very detailed information on creating applications with several goals in the documentation issued by the apple you can download it from the iPhone Dev Center you need to read this guide "Xcode Project Management Guide"

+1
source share

All Articles