I have application made for iOS 4.2 and I was doing development in XCode 4.3.3 and testing it with iPhone 5.1 Simulator and everything worked fine. Recently I decided to test how application runs on iOS 6.0. When trying this, I face two problems:
So, I open application with XCode 4.5 and run it on iPhone 6.0 Simulator. I have problems oft with starting application. XCode just says: Finished running on iPhone 6.0 Simulator, stop button is grayed (like app is not running) and iPhone simulator just shows black screen and nothing happens. I have to CMD+Q it. And this is for me HUGE problem, since I manage to run application successfully randomly after lots of failures.
Eventually and sometimes, application runs without problems and I see that emulator is running my application. Application is made in landscape mode only. But when simulator runs application, it stays in portrait mode and shows application designed for landscape screen in portrait mode. I have set Supported Interface Orientations to both landscape variants and in Application-Info.plist are these two landscape orientations also listed.
Does anyone know what's happening and possible solution?
Many thanks in advance.
[edit #1: Added All Output console message]
Console message (for problem 1 which now keeps occurring) says:
error: failed to attach to process ID 0
[edit #2: Small progress in solving 1st problem]
Okay, strange things are happening. First thing I did in order to eliminate error from edit #1 was:
In XCode go to: Product -> Edit Scheme -> Run [AppName].app -> Debugger and change it from LLDB to GDB
After this, error from edit #1 is gone, BUT there's new problem. After I run application now I get status message in XCode: Attaching to [AppName] and XCode is stuck on that action.
If anyone gives me an answer, I want to say that I tried everything from the list below:
and all kinds of these action permutations. Simply, I always see this problem. Best thing which happened to me was during this combination:
Open only XCode without opening project -> Go to Window -> Organizer -> [ProjectName] and delete it completely -> Quit XCode -> Open iPhone simulator and reset settings -> Quit iPhone simulator -> reboot Mac -> reopen XCode and run application
Sometimes in this case simulator managed to run my application right away, which is great. But after closing simulator and running application from XCode again (without doing anything between these two actions), XCode is stuck again on Attaching to [AppName] and won't start simulator with my application.
Although simulator won't start with my application from XCode, application itself is stored on simulator, and if I run simulator separately and start my application manually, application manages to start, but with 2nd problem I have in my problem description - layout issue.
[edit #3: XCode version info]
I forgot to mention my XCode version: Xcode Version 4.5 (4G144l)
[edit #4: "Solution"]
I found "solution" (I say "solution", since I haven't managed to find one in current XCode version).
I have just downloaded XCode Version 4.5 (4G182) and run my application normally (without changing Debugger to GDB) and everything's working fine except layout problem, which is definitely present because some changes made to iOS 6.0 comparing to iOS 5. I suppose this in fact is solution, since this version of XCode I used originally won't be used, since it was some of beta versions.
So, 1st problem is solved, still didn't manage to solve problem with layout.
[edit #5: Final solution]
Okay, 2nd problem solved. For all informations about my 2nd problem, here's the answer on this link: http://yusinto.blogspot.de/2012/08/ios-6-auto-rotate-and-orientation.html
Like I said in my edits, solution to my 1st problem was updating XCode to Version 4.5 (4G182). Solution to my 2nd question was replacing deprecated iOS 5 method:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
with 2 new methods introduced in iOS 6:
- (NSUInteger)supportedInterfaceOrientations
- (BOOL)shouldAutorotate
After that, app works just fine.
[edit #1: Adding working sample of landscape only app with iOS 5 and iOS 6 support]
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.viewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
MainViewController.m
#pragma mark - Orientation support
- (BOOL)shouldAutorotate {
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}