can i release an app which targets iPhone for the iPad? - iphone

I'm working on an iPhone app, and decided to look into making it universal. If I set my build settings to target iphone/ipad, a lot of sizes and alignments get buggered (as I expected), and just generally it doesn't look good.
If I only target iPhone, but run it on the iPad, and hit the 2x button, it looks great. I'd like to release my app on the app store for the iPad, despite leaving the targeted platform as the iPhone since it looks and works much better.
I'm wondering if that will be an issue when I submit? Can you only release apps for iPad on the store if they target iPad?
Thanks!

If you develop for the iPhone you will want to use interface "xib" files that have all the correct sizing for the iPhone/iPod. iPad will be allowed to use the application
In your plist you will have the option of giving a startup xib file [NSMainNibFile] for the application to start with.
Or you can alternatively include [NSMainNibFile~ipad] and compile it for Universal. This will tell the ios that it should open NSMainNibFile for the iPhone/iPod and should open NSMainNibFile~ipad for the iPad.
There are a number of other settings that would need to be set for the ipad's icon, default screen among other items. But the Nib file settings are the most needed.
then you have separate xib file's for each platform. Conforming to the Model-View-Controller setup it would be relatively simple to attach your new view(xib) to your existing controller(.h/.m) and wire up a new look to your code and make an entirely new app..
Some sections of code will need to be changed dependent on weather you are on the iPad or the iPod.
(e.g. Layout, Special iPad/iPod only features etc.)
Here is the code I use do determine if I am on the iPad.
#define IS_IPAD() ([[UIDevice currentDevice] respondsToSelector:#selector(userInterfaceIdiom)] ? \
[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad : NO)
Some developers dont comply totally with the MVC paradigm so your project may require some retooling to be able to function on both platforms. But if you are able to pinpoint the places that differentiate from one platform to another then your application will be able to function seamlessly on both platforms. (Likely with a better layout on the iPad as there is more real estate do play with when laying out your controls)
Alternatively if you want the application to be iPhone style but run on the iPad, It already does that by default.

If you target the iPhone (so that it will appear in 1x/2x mode on the iPad) it will only appear in the iPhone App Store.
iPad Users will still be able to download the app, but it will be in the iPhone Apps section.
So unless you explicitly target the iPad, it won't appear on the iPad store. You could consider redoing the graphics and alignments for the iPad app and sell it as a HD app.
If you need it to be universal look at doing something like this:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
controller = [[MyController alloc] initWithNibName:#"MyiPadNib" bundle:nil];
else
controller = [[MyController alloc] initWithNibName:#"MyiPodNib" bundle:nil];

You application will only be viewable in the iPad section of the store if it specifically targets iPad (is either iPad only, or a universal application).
What you are talking about is an iPhone application running on an iPad: where you are opting to only target iPhone devices. These apps will not be shown in the iPad section of the store.
Think of it as an incentive by Apple to get you to design an app that behaves well on iPad and iOS.
Remember, iPad users can still download iPhone only apps through the store, they're just in a separate section.

Related

Can we develop single app for iPhone and iPad

I’m new to iOS development and currently developing an app for iPhone and iPad.
My question is can we develop single app that can run on both iPhone and iPad which match their different screen sizes or resolutions . Or do I need to compile 2 different applications that match the different screen sizes or resolutions in iPad and iPhone?
Thanks.
Yes we can! Universal app is the solution!
Read this blog : http://www.kotancode.com/2011/04/05/ios-universal-apps/
We can develop single app to achieve this. Just select Device family as universal while creating new project. You will get option to prepare different Xib's for iphone and ipad. In code, you can either check for the device or use proper naming while allocating it.
For example,
For iphone -
oneViewController *oneView = [[oneViewController alloc]initWithNibName:#"oneViewController" bundle:nil] autorelease];
For ipad - You can just use "oneViewController~ipad" as xib name. This will automatically load xib for ipad.
you can make one universal app for both iPhone and iPad. Create different layout for both either using storyboard or nib files.
Firstly you don't need to compile 2 different applications that match the different screen sizes or resolutions in iPad and iPhone. There are already universal app in AppStore.
Try this:Universal-iOS-App-Template And this question:iPad/iPhone universal app

Converting an iPhone app to an iPad app in XCode 4

I had created an iPhone app long time back. Now I want to kind of convert the same into an iPad app (the code would more or less remain the same, I only want to redesign the xib for iPad size).
Now I am using XCode 4 and after opening the app, I changed the devices to iPad. But my .xib are still showing iPhone size.
It created an iPad folder (just like Classes/Resources/Products...).
Also to add, the app now opens an iPad simulator, but let's say I have a UIWebView which just stretches to iPhone size (as in IB) and not the complete iPad size...
How and where do I redesign the xib for iPad ? What are the updates to be made when we just change the devices from iPhone to iPad ? Also I guess an iPhone app would work on iPad (using 2x), but the reverse is not true.
You should look into creating a Universal app which basically has shared code and libraries for the iPhone and iPad but different view layers (views or XIBs).
In that model you have different interfaces for both which you should. The paradigms are different - in iPhone you have small real estate so you have navigators that drill in and pop out. In iPad, you have more real estate so you have master/detail splitter views with pop-over controls. As you pointed out, even the web views are different sizes at a minimum.
If you start fresh you can create a universal app and get a feel for how it's laid out. File, new project, iOS, pick app type, next. For device family select Universal.
If you are converting, there's some resources out there. Here's some:
http://useyourloaf.com/blog/2010/4/7/converting-to-a-universal-app-part-i.html
How to convert iPhone app to universal in xcode4, if I previously converted, but deleted MainWindow-iPad?
Convert simple iPhone app to Universal app
I find it easiest to open the xibs in the separate Interface Builder that came with previous (3.2?) XCode and use its "convert to iPad using autoresize masks" option. Then I include the new separate XIBS in the project and do conditional loading (eg - use the UI_USER_INTERFACE_IDIOM() makro to load one xib or another.)

How to make an iphone and iphone4-retina compatible app (done in cocos2d) easily adapted to ipad?

My question is simple:
1. I made an iphone app all done in cocos2d.
2. I adapted it to iphone4-retina, with all PNG files have their -hd copy.
Run in iPhone, the app displayed correctly (320x480).
Run in iPhone4-retina, the app also displayed correctly (640x960).
But run in iPad, if the app is set to iPhone only, it run correctly, but only as iPhone resolution (320x480). If the app is set to iPhone/iPad, of cause it will display wrong.
I'm sure there should be an option that force a retina-compitable iPhone app also run as retina on iPad (apple guys cannot be silly enough to miss it), but I just couldn't find it.
Where's the option? Or, is there an alternative that cocos2d has a same-easy switch to do the job? I do not need suggestions such as using relative coordinates or anything requires modifications more than twenty code-lines.
As far as I know, there is no automatic adaptation of an iPhone app to iPad. You still should be able to create a universal app for both iPhone and iPad and then re-create your UI based on whether you are running on one device or the other.
Specifically, you could:
Create an XCode project for a universal app (armv6 and armv7, targeting iPad and iPhone) and import there your existing project (source, resources, settings).
1b. (you could modify your existing project, but this could be trickier to do correctly.)
add icons and default images as per iPad guidelines in addition to those you have for iPhone;
As to the rest, you could follow a similar approach to the one highlighted here for Xibs:
test for iPad:
+(Bool)isIpad{
return ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
}
translate image name before loading:
+(NSString*)properImageFileName:(NSString*)imageName {
if ([xxxx isIpad]) {
return [NSString stringWithFormat:#"ipad_%#", imageName];
} else {
return imageName;
}
}
Thus, if you are on iPhone, image names are not changed and will follow the iPhone convention for retina display; if you are on iPad, you change the name on the fly and use the right image. (of course, you can use the convention you prefer to identify iPad images).
This should make it pretty trivial, but keep in mind the size toll that having all the images in your universal app tolls.

iOS Development: How can I prevent an iPad from running a universal app in iPad mode?

I'm diving into iOS development and I created a universal app that turned into an iPhone-only app. When it runs on the iPad, it just loads a white screen since there's no iPad code written yet. What I'd like is for it to run in "iPhone" mode on the iPad, if it somehow ends up on an iPad. I have the "Targeted Device Family" property set to "iPhone", so that should prevent it from showing up in the App Store as an iPad app, but if anyone owns both an iPad and an iPhone, then the app could end up synced to the iPad, at which point it will just load the white screen because it will try to run the app in iPad mode, which it doesn't have any code to support. In this situation, I prefer that it actually ran on the iPad, but in iPhone mode.
My questions are...
When an iPad runs a universal app, how does it know to run it in "iPhone mode" or execute the iPad specific code?
In a universal app, how does it know which code is iPhone and which code is iPad?
How can I prevent the iPad from trying to run the iPad code and, instead, run the iPhone code?
I apologize if I sound like a total noob, but I am. Thanks so much for your wisdom!
The iPad looks into the application's Info.plist, for the UIDeviceFamily key, which is an array. The value '1' indicates iPhone/iPod Touch, '2' indicates 'iPad'. If there's a '1' but no '2' then you get the simulated iPhone environment. This value is written to the Info.plist automatically as a result of your 'Targeted Device Family'. If you think you've set it to iPhone but are still getting an iPad build, check you didn't just set it for one build configuration. Check the Info.plist within your produced app bundle if you want to be really confident.
There's only one binary, which you write to launch correctly on either device.
Just don't target the iPad.
I'm assuming what you actually want is to remove the "universal" capability, and just make it an iPhone app.
In Xcode, go to Project => Edit Project Settings => Build.
Search for universal, or 'Targeted Device Family'.
Pick iPhone.
Goodbye iPad.
When an iPad runs a universal app, how does it know to run it in "iPhone mode" or execute the iPad specific code?
The iPad looks for the Targeted Device Family, if the iPad is not present, then it knows it must run the app in iPhone mode.
In a universal app, how does it know which code is iPhone and which code is iPad?
When you write the code for the app, you must specify what device you are targeting if there are specific things you need to do per device. (see the code example below)
How can I prevent the iPad from trying to run the iPad code and, instead, run the iPhone code?
Do not support iPad in your Targeted Device Family. Second, in your code, do not specify that specific code needs a specific device, for example:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
/* run something specific for the iPad */
}
else
{
/* run something specific for the iPhone */
}
If you build an universal app, it will use your iPad code. It is not possible to run a universal app in "iPhone Mode". Apple will check that you have followed the iPad design specifications.
In a universal app, there are two app-delegates: AppDelegate_iPhone.h and AppDelegate_iPad.h
You can add your iPhone code in the AppDelegate_iPad, but Apple will not be pleased.
You should NOT add this to your Info.plist file. Instead, add it to your build settings per Apple's suggestion. Specifically, use the TARGETED_DEVICE_FAMILY build setting.
If you are using storyboards, you also want to remove the UIMainStoryboardFile~ipad key from your Info.plist as it will be used regardless of your TARGETED_DEVICE_FAMILY setting.
Good luck!
I think there is an entry in the info.plist file for each of the devices that says which main window to load.
Maybe a quick and dirty solution would be to set both MainWindow-iPhone and MainWindow-iPad to the same -iPhone- main window.
Another way to do it (with code) is:
In your App's AppDelegate (if your App was created as an Universal App) you can find the following code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
//iPad...
} else {
//iPhone and iPod Touch...
}
return YES;
}
There you can customize what view to show.
Since Xcode 5, you can chose your development target devices from the Project:
From the devices section within Development Info, now you can choose:
1-iPhone 2- iPad 3- Universal
I think that something is wrong with your configuration, because if you target the code for iPhone only Device, the app will bu runnable on an iPad with the screen that was designed for iPhone (so, reduced, with the possibility to x2).
the proposals from the AppStore (iPhone/iPad/both) depend on the user's preferences
you can experiment it with the Simulator (and choose iPad as the Device)
the code is the same for iPad/iPhone ! ... unless you use [[UIDevice currentDevice] userInterfaceIdiom] mentioned supra...

iPhone project to iPad project in xcode?

I'm wondering if it's possible to make the iPhone app project I have into an iPad project? So I won't have to redo all coding and connecting everything again. I've gotten that far that I can make the iPhone project run on the iPad but then it's only in the iPhone's size.
I hope this makes sense!
Thank you in advance.
You'll probably need to recreate all those views as iPad views instead of iPhone views. Both would be included into the universal app in a single distribution binary. At runtime, load them dynamically based on the platform.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// The device is an iPad running iOS 3.2 or later. load the appropriate Xibs
}
else {
// The device is an iPhone or iPod touch. load the appropriate Xibs
}
See Creating a Universal Application
You may be able to design some views to dynamically stretch / resize and won't have to touch them much, however I suggest you tailor the tablet experience more than just "upsized", otherwise you aren't doing the device justice.