0

I have 2 projects - one is iPhone, the other is iPad project. I want to integrate them into a universal application in order to upload to the Appstore. How can I do that?

Varun Mulloli
  • 658
  • 13
  • 28

2 Answers2

1

The easy way to discover the answer is to start with a working Universal app. So, for example, start with the Master-Detail Application Template and make a new Universal project. Look at how it is structured. It has two storyboards, depending on which platform we are on. And some code is conditional, again depending which platform we are on.

So you would combine your code / interface like that, in whatever way makes sense to you. The business with separate interfaces is easy (separate but parallel storyboards, nibs, whatever); the hard part is what to do about code which is partially shared and partially not. It is very annoying to have to maintain a lot of conditional code, so sometimes it is easier to have completely different classes, one which you will use on iPad and another which you will use on iPhone.

My book has some suggestions about how to test which set of code to use depending on which platform you're on:

http://www.apeth.com/iOSBook/ch09.html#_choosing_a_device_architecture

Scroll down to the end of that section for some important hints about that.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • The problem is in two projects, there are some class has the same name (.h and .m but not the same implementation) because there are two team make those projects and not at the same time, so may i have an efficient way to integrate two projects without rename the class ? Thanks in advance. – Thanh Tung Ho Nov 27 '12 at 04:56
  • Why not rename the class? It's easy with Edit > Refactor. I've already explained that you're going to have to do some editing. Either you're in control of this code or you're not. If you're not in control of this code, you cannot do what you're asking to do, and should stay away from the whole thing. – matt Nov 27 '12 at 17:12
-1

In the app project, go to TARGETS and select the first item, then under the summary tab select Devices and change it to universal, then copy all of the iPad files to the other project, or if you do it in the ipad project copy all of the iphone files, and then make sure all the .m's are compiling (check in the Build Phases tab, i have had issues where xcode didnt add the files to compile), then in the app delegate make sure you check for ether its a iphone device or ipad device and show the appropriate xib, or if your using storyboards just put the name of the iphone storyboard also in that summary tab.

Maximilian Litteral
  • 3,059
  • 2
  • 31
  • 41