Make iPhone app compatible with iOS 3 - iphone

I have developing an iPhone application using xcode 4 which is compatible with iOS 4.3 and runs on iPhone 4 device smoothly. My question is how to check whether my application is compatible with iOS 3 or not.I do not have any iOS 3 device to run the app so the only solution is to check the compatibility for iOS 3 is simulator but I have not found any option to run the app on iOS 3 simulator.
Any suggestion how to install SDK for iOS 3.
Thanks

The only way to be sure of compatibility is to borrow or buy a device running iOS 3 for testing. The Simulator, even an old one, is not accurate enough to ensure compatibility.
If you can't find a device still running 3.x anywhere, even just to borrow for an hour, why bother with compatibility with such a rarity?

Here's my checklist for iOS 3:
make sure that your app runs fine on slow CPU and less memory.
support armv6. add armv6 to architectures, remove armv7 from required device capability, and disable thumb on armv6 if your compiler has code generation bug.
don't use ARC, whick is not (officially) supported on iOS 3.
check for existence of newer method (with respondsToSelector:) or class, instead of checking the OS version in most cases.
don't use gesture recognizers which did exist on iOS 3 but were private API, and lack important methods. you need to handle touch events manually.
if you use blocks, you need to link the system library dynamically, and it requires iOS 3.1 (I've heard that iOS 3.0 doesn't support dynamic link.)
Here is an example application:didFinishLaunchingWithOptions: method.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
if ([self.window respondsToSelector:#selector(setRootViewController:)]) {
self.window.rootViewController = self.viewController;
} else {
[self.window addSubview:self.viewController.view];
}
[self.window makeKeyAndVisible];
return YES;
}

Tap the project, tap your target, tap Summary, set your Deployment Target to 3.x. Then the Scheme pulldown in the top of XCode will show you options to run it in the 3.x simulators.

On the iOS developer center there's a download link to Xcode 3. That one might include iOS 3.

Related

Supporting iOS 4.3 to iOS 6.0

I already have the base code that supports ios 4.3 to ios 5. Now I would also like to support ios 6.0.
The present base code has modal views, hard coded CGRect's, and rotation is different for each view. So I would like to know whether we can support ios 4.3 to ios 6.0 with the same base code, by just tweaking some changes, or do we need to create a complete new target?
Like we cannot use auto layout of ios 6.0 if I want to support previous versions as it will lead to a crash.
Yes, we can do this by setting up the Deployment Target to iOS 4.3. But then, why do you need to support iOS < 5.0 as around 85-90% of devices are on iOS 5.0+. See this
Also, when you set up support for iOS 4.3 or even iOS 5.1.1, you would have to handle multiple things. For example, the method for Orientation,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
isn't called for iOS 6. It is replaced by the methods,
- (NSUInteger)supportedInterfaceOrientations
- (BOOL)shouldAutorotate
You would need all the iOS versions on devices and then test each and every aspect of your app.
Using Xcode 4.5 it is perfectly valid to use one code base for building iOS 4.3 - 6.0 apps, but as always the key is testing on real iDevices with the given operating system versions.
Yes it is perfectly fine and can be done to support ios 4.3 to ios 6.0 using the xcode 4.5.
And for the orientations in ios 6 have to do some work around like have to put some code differently as posted in #Mayur J's answer.
Or all you can do is just add categories for the required controller's like UINavigationController, UIPopoverViewController, UIImagePickerViewController, etc to return the supported orientation in ios 6.0 like below
.h file
#import <UIKit/UIKit.h>
#interface UIPopoverController (UIPopoverController_Orientation)
-(NSUInteger) supportedInterfaceOrientations;
#end
.m file
#import "UIPopoverController+UIPopoverController_Orientation.h"
#implementation UIPopoverController (UIPopoverController_Orientation)
-(NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
#end
Here I use UIInterfaceOrientationMaskLandscape as I only supports landscape orientations ie restrict my app to only landscape mode.
Hope this will help you.
Happy Coding :)

App Rejected for failing to launch? ...and others

My game was just rejected from the AppStore for the following two reasons...
We found that your app failed to launch on iPhone 4 running iOS 5.1,
on both Wi-Fi and cellular networks.
We encountered the issue when selecting the application on the Home
screen - the app displayed a launch image then quit unexpectedly
And
Your app did not run at iPhone resolution and/or 2x iPhone 3GS resolution when reviewed on iPad.
Both of these confuse me, I currently do not have Lion installed so cannot test in 5.1 but, it works just fine in 5.0.1 and below.
Also, I have been testing on only my iPad, have no iphone to test on, but the game and graphics run just fine on the iPad. Though! I only have graphic files labeled #2x.png, and none with out it. Could that be the problem here?
If anyone has any advice that would be awesome, I responded to apple's rejection, but i bet it takes a while for them to get back to you, and i'd really like to move this along. Thanks!
**Updated
My didFinishLaunchingWithOptions:
Is as follows
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
mainMenu = [[MainMenu alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:mainMenu];
self.navController.navigationBar.hidden = YES;
[self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
[[GCHelper sharedInstance] authenticateLocalUser];
if ([[[NSUserDefaults standardUserDefaults] objectForKey:#"missingWordsAdded"] intValue] != 1) {
[self forceAddWords];
}
if (![[NSUserDefaults standardUserDefaults] objectForKey:#"EnableSoundEffects"]){
[[NSUserDefaults standardUserDefaults] setObject:#"YES" forKey:#"EnableSoundEffects"];
}
return YES;
}
GCHelper sets up GameCenter. thanks!
I've got a few suggestions:
Do a reset on your simulator, launch your program and see if it works
Uninstall your app from iPad, run it from Xcode and see if it works
Ask a friend to test an ad-hoc copy, or attach to your Xcode and run debug copy
Depending on your implementation, you should do some blind check on your startup code (didFinishLaunchingWithOptions or singleton instances). Especially those area that involves GCD, #synchronize, access on NSArray or NSDictionary. And things like default preference initializing and database creation are likely to produce this kind of problem.
Regarding the review process, my log indicates that Apple staff at Cupertino uses an iPad 2 with WiFi connection to run your app. They are not toying with you if they say they can't run your app.
1) "app failed to launch" for different configurations of phone and iOS is a big issue to reproduce because you may not have all the phones with different iOS versions at hand. You can try https://testflightapp.com/ for example, and can come to know your app performance with different configurations.
my app is also rejected for same reason. here u have first check the internet connectivity where it will needed than u have do your code.
to check internate connectivity u can use reachability classes.

App shows white screen on startup after upgrading to iOS 4.2

For the past few weeks I have been working on an app that uses a SoundManager class that I found via the comments of this blog post:
http://www.gehacktes.net/2009/03/iphone-programming-part-6-multiple-sounds-with-openal/
The link to the SoundManager and tester app is provided in the comments by David Evans. I am not allowed to provide a second link so I'll mention the name of ZIP file he links to:
SoundTester.zip
I was very happy with this code, until iOS 4.2 was released. After updating my iPad and Xcode correspondingly, my apps that use the SoundManager class only show the navigation bar with it's title. The rest of the screen is white. It's not iPad specific behavior. I have seen the same on an iPhone4 and an iPhone 3G that upgraded to iOS 4.2.
When running the apps in the simulator, I get the same results. The problem is that I get no error messages in the console window and no build and compile errors at all. Very frustrating and very hard to fix for an iPhone developer that started using the iPhone SDK only months ago.
Does anyone have a clue what could have gone broken and how to fix it? Any help is appreciated!
Somebody please shoot me...
Just found the problem, with the help from a piece of code I had written down from the iPhone Developer's Cookbook.
The problem was not the SoundManager (which still works fine, fortunately!) but in the application:didFinishLaunchingWithOptions: method in the App Delegate class.
Here is the code that causes the problem in iOS 4.2 but still works in iOS 3.2:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Create a Navigation Controller on the fly.
// Use the View Controller as root view controller.
viewController.title = #"ThreeSounds";
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
nav.navigationBar.barStyle = UIBarStyleBlack;
// Add the view controller's view to the window and display.
[window addSubview:nav.view];
[nav release];
[window makeKeyAndVisible];
return YES;
}
The solution: remove the line that says: [nav release].
For some reason, releasing the navigation controller was not a problem in iOS 3.2.
In iOS 4.2 is makes the screen go white.
I found out that this method was the problem because it was the last method that was executed. That, in turn, I found out by adding this piece of code to every class in my project:
-(BOOL) respondsToSelector:(SEL)aSelector {
printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]);
return [super respondsToSelector:aSelector];
}
This piece of code logs all the methods that get called.
I used the following code in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if (!window)
{
[self release];
return 0;
}
This method caused white screen when I launched my app. It was OK in 3.2 / 4.0 SDK. In SDK 4.3 it is causing the problem. Just comment or remove this code if you have it.
I had same problem. The problem was duplicated UIWindow.

Any tips on how to create apps that run on iOS 3 and iOS 4?

Hey,
I'm developing an iPhone application and my target is 3GS and 4G devices.
iOS 4 introduces methods thats deal with multitasking and newer methods to deal with foreground/background lifecycle events.
These new methods aren't available in iOS 3 which simply quits the app and doesn't run it in the background.
Any tips on how to create apps that run on iOS 3 and iOS 4?
The iPad Programming Guide (I know, not what you'd expect) has a section on universal apps that shows you how to check that symbols exist at runtime. It applies to your question as well.
Start here:
https://developer.apple.com/library/ios/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html#//apple_ref/doc/uid/TP40009370-CH9-SW3
I put all my ios4 functions in one section, then wrap a compiler macro(so xcode lets you compile) around them and have functional checking inside each function(so once compiled, your code runs without crashing).. for example
//Define Logic for conditional code based on version of iOS
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
- (void)applicationDidEnterBackground:(UIApplication *)application {
//SPECIAL CASE:For OS versions before 4.0, background processes are not supported
if (backgroundSupported) {
<IOS4 CODE GOES HERE>
}
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
if (backgroundSupported) {
if (backgroundSupported) {
<IOS4 CODE GOES HERE>
}
}
- (BOOL)checkBackgroundSupported {
UIDevice* device = [UIDevice currentDevice];
backgroundSupported = NO;
if ([device respondsToSelector:#selector(isMultitaskingSupported)])
backgroundSupported = device.multitaskingSupported;
return backgroundSupported;
}
#endif

How do I write an iPhone/iPad app to take care of different screen sizes?

With the new iPad (which has a different screen resolution of the iPhone/iPod Touch), how do I set the application to automatically size appropriately to the desired screen size?
Read the iPad Programming Guide in the 3.2 SDK beta documentation. It will tell you everything you need. The NDA means we can't talk about it here publically.
Although the iPad SDK is still under NDA at this time, the iPhone SDK which preceeds it introduced the ability to change the screen size:
- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)opts
{
UIScreen *s = [UIScreen mainScreen]; // ask for the main screen
[window setFrame:[s applicationFrame]]; // get the application Frame for the screen
return YES;
}
If you have used NIBs for the UI construction, you need to ensure that they're auto-resizable in order for them to flow properly.
The issue is not in the code. It is in the project conversion from iPhone to iPad: http://www.cocos2d-iphone.org/forum/topic/4108