iOS 6 Orientation Crash

So I’ve just updated xCode and got hold of iOS6 - late I know.

But unfortunately noticing that my app is crashing shortly after launch on the xCode Simulator. The app is intended to be used solely in one landscape orientation and worked on device/simulator prior to iOS6.

However now the app boots up - show the menu screen and shortly crashes with the following error:

Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES

Does anybody have nay knowledge of this? Not sure whether iOS 6 needs any changes to the build.settings file, currently I have the following for orientation settings:

settings = {  
 orientation = {  
 default = "landscapeLeft",  
 supported = {"landscapeLeft"},  
 },  

Which as I said worked fine on iOS5.

Any help would be appreciated. [import]uid: 33275 topic_id: 31056 reply_id: 331056[/import]

P.S Think it could be related to this - Game Center on iOS6 in landscape only orientated apps:

http://stackoverflow.com/questions/12427979/ios6-gamecenter-authentication-in-landscape-only-app-throws-uiapplicationinvali

I’ve reported the bug with Apple as it seems to be an issue with iOS6 - however would appreciate if anybody has any workarounds or facing a similar issue?

P.P.S 100% Game Center related as I stopped the initiation call to GC and voila - no crash! [import]uid: 33275 topic_id: 31056 reply_id: 124142[/import]

So Apple seem aware of this bug and issues the following work around, not sure whether that helps us with Corona:

Game Center
Landscape-only apps that invoke a portrait-only view controller (such as the Game Center login screen) will cause the app to crash.
Workaround:

Apps should provide the delegate method application:supportedIntefaceOrientationsForWindow and ensure that portrait is one of the returned mask values.
When a UIBNavigationController is involved, subclass the UINavigationController and overriding supportedInterfaceOrientations.

I’d appreciate it if anybody from Corona would be able to chip in with a comment as to whether this is useful for us - hoping Apple will squash this bug before iOS is put on general release, but fearing they might not. [import]uid: 33275 topic_id: 31056 reply_id: 124149[/import]

We were hit with this as well. If your game only supports landscape, try the following:

Make sure your build.settings orientation block contains the following:

default = “landscapeRight”,
content = “landscapeRight”,
supported =
{
“landscapeLeft”, “landscapeRight”, “portrait”
},

You need to specify that you support all three orientations, but that the default is a landscape and that the content is always landscape. Below, in your iphone.plist block, ensure you have the following:

UIInterfaceOrientation = “UIInterfaceOrientationLandscapeRight”,

UISupportedInterfaceOrientations =
{
“UIInterfaceOrientationLandscapeRight”, “UIInterfaceOrientationPortrait”
},

This allows the GC to come up. It’ll be in portrait orientation rather than landscape, but at least your app isn’t crashing. [import]uid: 117383 topic_id: 31056 reply_id: 124195[/import]

Thanks Kimberly - works like a charm. [import]uid: 33275 topic_id: 31056 reply_id: 124204[/import]

We just found a gotcha - native widgets (like textField) are rendered at a 90 degree rotation. :frowning:

Edit: nix that. Native controls are rendered at 90 degress in landscape mode regardless of the suggestion I made above. Bug being logged now. [import]uid: 117383 topic_id: 31056 reply_id: 124214[/import]

We are aware of the GameCenter bug and it’s a documented bug from Apple. I think your solution to allow Portrait mode and fix the content at Landscape is a good solution for now.

We are also aware of the native.newTextField and TextBox bug where it doesn’t work in Landscape mode. There is also a problem where Autorotation doesn’t work for all display objects. Apple changed the way they handle rotation in iOS6 and we are looking into the changes now. [import]uid: 7559 topic_id: 31056 reply_id: 124248[/import]

Seems as though build .914 fixes this issue for me. [import]uid: 33275 topic_id: 31056 reply_id: 124337[/import]

Build 914 fixes the rotations issues but we don’t think it fixes the GameCenter crash. The workaround above is the best solution for now.

There still is one other iOS6 issue we are looking at. Apple removed the ability to display “printf” messages in the Xcode Console so none of the Corona print statements or runtime errors will be displayed. We are trying to find a way to fix that but it’s not an easy fix (if we can even do it).

Let us know any other iOS6 problems you find.

Thanks,
Tom [import]uid: 7559 topic_id: 31056 reply_id: 124366[/import]

Logging is the only big one left for us that we’re 100% sure about although we have some reports of folks having issues with IAP on older 6.0 builds (but we can’t reproduce those).

As for the logging, I’m going to try and temporarily replace the print function with one that writes to a file in the document directory. It’s not ideal, but at least we can see what’s happening after the fact. [import]uid: 117383 topic_id: 31056 reply_id: 124368[/import]

P.S Think it could be related to this - Game Center on iOS6 in landscape only orientated apps:

http://stackoverflow.com/questions/12427979/ios6-gamecenter-authentication-in-landscape-only-app-throws-uiapplicationinvali

I’ve reported the bug with Apple as it seems to be an issue with iOS6 - however would appreciate if anybody has any workarounds or facing a similar issue?

P.P.S 100% Game Center related as I stopped the initiation call to GC and voila - no crash! [import]uid: 33275 topic_id: 31056 reply_id: 124142[/import]

So Apple seem aware of this bug and issues the following work around, not sure whether that helps us with Corona:

Game Center
Landscape-only apps that invoke a portrait-only view controller (such as the Game Center login screen) will cause the app to crash.
Workaround:

Apps should provide the delegate method application:supportedIntefaceOrientationsForWindow and ensure that portrait is one of the returned mask values.
When a UIBNavigationController is involved, subclass the UINavigationController and overriding supportedInterfaceOrientations.

I’d appreciate it if anybody from Corona would be able to chip in with a comment as to whether this is useful for us - hoping Apple will squash this bug before iOS is put on general release, but fearing they might not. [import]uid: 33275 topic_id: 31056 reply_id: 124149[/import]

We were hit with this as well. If your game only supports landscape, try the following:

Make sure your build.settings orientation block contains the following:

default = “landscapeRight”,
content = “landscapeRight”,
supported =
{
“landscapeLeft”, “landscapeRight”, “portrait”
},

You need to specify that you support all three orientations, but that the default is a landscape and that the content is always landscape. Below, in your iphone.plist block, ensure you have the following:

UIInterfaceOrientation = “UIInterfaceOrientationLandscapeRight”,

UISupportedInterfaceOrientations =
{
“UIInterfaceOrientationLandscapeRight”, “UIInterfaceOrientationPortrait”
},

This allows the GC to come up. It’ll be in portrait orientation rather than landscape, but at least your app isn’t crashing. [import]uid: 117383 topic_id: 31056 reply_id: 124195[/import]

Thanks Kimberly - works like a charm. [import]uid: 33275 topic_id: 31056 reply_id: 124204[/import]

We just found a gotcha - native widgets (like textField) are rendered at a 90 degree rotation. :frowning:

Edit: nix that. Native controls are rendered at 90 degress in landscape mode regardless of the suggestion I made above. Bug being logged now. [import]uid: 117383 topic_id: 31056 reply_id: 124214[/import]

We are aware of the GameCenter bug and it’s a documented bug from Apple. I think your solution to allow Portrait mode and fix the content at Landscape is a good solution for now.

We are also aware of the native.newTextField and TextBox bug where it doesn’t work in Landscape mode. There is also a problem where Autorotation doesn’t work for all display objects. Apple changed the way they handle rotation in iOS6 and we are looking into the changes now. [import]uid: 7559 topic_id: 31056 reply_id: 124248[/import]

It’s certainly not the prettiest or efficient bit of code - and I haven’t tested it extensively, but this should help anybody who’s struggling with the lack of print statements on device in xCode following iOS6/xCode 4.5.

Simply put a blank log.txt file into your build directory and refactor the following code into main.lua:

releaseBuild is a global variable (nasty I know) to decide whether I want to actually print stuff to a file or not for the final build - simply define it above in main.lua and set to true or false.

if releaseBuild then  
 function print() end  
else  
 function print(statement)  
 local statement = statement  
 --print(tostring(statement))  
 local path = system.pathForFile( "log.txt", system.DocumentsDirectory )   
 local file = io.open( path, "a+" )  
  
 if type(statement) == 'table' then  
 local t = statement  
 for k,v in pairs(t) do  
 if type(v) == 'function' then  
 table.remove(t, k)  
 end  
 end  
  
 local jsonString = json.encode(t)  
  
 for k,v in pairs( t ) do  
 if v.type ~= 'function' then  
  
 file:write( k .. "=" .. v .. "," )  
 end  
 end  
 else  
 -- Creates the file where we save our data if needed  
 file:write(statement.."\n")  
 end  
  
 io.close( file )  
 end  
end  

You’ll have to download the xcappdata file from Xcode and click ‘Show Package Contents’ to actually be able to check out the log.txt file.

Seriously hoping Corona can work around the print obstacle to avoid having to log print statements to a file. [import]uid: 33275 topic_id: 31056 reply_id: 124699[/import]

Seems as though build .914 fixes this issue for me. [import]uid: 33275 topic_id: 31056 reply_id: 124337[/import]

Build 914 fixes the rotations issues but we don’t think it fixes the GameCenter crash. The workaround above is the best solution for now.

There still is one other iOS6 issue we are looking at. Apple removed the ability to display “printf” messages in the Xcode Console so none of the Corona print statements or runtime errors will be displayed. We are trying to find a way to fix that but it’s not an easy fix (if we can even do it).

Let us know any other iOS6 problems you find.

Thanks,
Tom [import]uid: 7559 topic_id: 31056 reply_id: 124366[/import]

Logging is the only big one left for us that we’re 100% sure about although we have some reports of folks having issues with IAP on older 6.0 builds (but we can’t reproduce those).

As for the logging, I’m going to try and temporarily replace the print function with one that writes to a file in the document directory. It’s not ideal, but at least we can see what’s happening after the fact. [import]uid: 117383 topic_id: 31056 reply_id: 124368[/import]