It’s Wednesday and time for another FAQ session. Here are some frequently asked questions (FAQ) about current iOS 6 bugs.
1. Why does GameCenter crash my app on iOS 6?
As I mentioned in a previous FAQ, there is a known iOS 6 Apple bug that causes landscape-only apps to crash when GameCenter sign-in screen or the photo picker is displayed. These native objects only work in portrait mode on iPhone devices. When these objects are displayed in a landscape app, the app will crash. There is no problem with iPad. This is a documented Apple bug.
2. I see a number of GameCenter work-arounds on StackOverflow.com. Why can’t you include those fixes in Corona?
We have seen the work-arounds on the Internet and on the Apple Developer forum and tried to come up with a working solution. The solutions address the issue with GameCenter and how to make it come up in portrait mode, and have the rest of your app work in landscape. What they don’t address (or even mention) is that allowing GameCenter to work in portrait mode also allows any UIViewController objects to show in portrait mode too. This means TextField, TextBox, webViews rotate along with the GameCenter object.
We spent the last few days trying out these work-arounds in order to find a solution that allows GameCenter object to rotate to portrait mode (so it doesn’t crash) but doesn’t allow other native objects to rotate. We haven’t found anything that works using Apple approved APIs. We have found a solution that does work but it uses Apple private APIs. Apple prohibits the use of private APIs so that’s not a suitable solution because of the chance of rejection by Apple for any app submitted to the App store.
3. How can I configure my app to work around the GameCenter iOS 6 bug?
UPDATE: We have an updated post with a proper workaround to the Game Center/Landscape/iOS 6 bug.
If your app only runs in landscape mode and you need GameCenter (or Photo Picker), you can configure build.setting to allow portrait mode for GameCenter/Photo Picker but restrict the Corona content to landscape mode. The limitation to this scheme is, 1) your app is limited to landscapeRight and 2) native objects (textFields, textBoxes, webView, etc.) will also rotate to portrait mode. There is no way we found that will allow GameCenter to rotate but keep the other native objects in landscape mode.
Note that the content = “landscapeRight” line. Corona limits this setting to only one orientation, which is why the supported orientations includes “landscapeRight” and not “landscapeLeft”. If “landscapeLeft” was included, the Corona content (display objects) would be fixed at landscapeRight but the native objects would also rotate to landscapeLeft (as well a portrait).
In build 926, we added a new GameCenter event.type that may help you code around some of the native object rotation issues. The change adds “showSignIn” as a new event.type for the GameCenter initCallback. This indicates that the GameCenter Sign-In object is about to appear (in portrait mode) and you can either remove, hide, or delay showing native objects. After the user signs in and the sign-in screen goes away, the initCallback is called with event.type == “init”. If the user is already signed into GameCenter, there will be no showSignIn event and it will go directly to the “init” event. You may also want to add an orientation listener because your native objects will still rotate to portrait mode if the user rotates the device. If the device is rotated you could either hide the native objects or anything else that would make sense for your game.
We understand that what is mentioned above is not an ideal fix but it’s the best we can do until Apple fixes their bug. We encourage everyone to file a bug report with Apple about this (and other Apple issues) so it’s resolved as soon as possible.
4. My app doesn’t use GameCenter but does use PhotoPicker and it crashes too. What can be done about that?
UPDATE: This issue only affects iPads running iOS 6. We have a workaround for this Apple bug coming.
The changes in build.settings (see above) will work for both GameCenter and PhotoPicker with the limitations listed above. The sign-in listener event.type only works with GameCenter and provides a hook that may allow a work-around. Again, please file a bug report with Apple so this issue is fixed soon.
5. Why does my iOS 6 app crash when I use network.request?
Apple made some changes to the network delegate that caused a race condition that would cause a crash in iOS 6 apps if network.request was called many times in a short period of time. We found a solution and added it to the next Daily Build (build 926 and later). There is a similar issue in the Mac Simulator and the fix in build 926 address that too.
6. Why can’t I see my print message in the Xcode Console?
As mentioned a few weeks ago, in iOS 6 Apple changed how they captured messages sent from within the application. This broke print messages going to Xcode Console (for devices connected to Xcode) and going to the Console app for the iOS Simulator.
The good news is we found a work-around for the issue and happy to announce that print messages are back starting with Daily Build 925.
That’s it for today’s questions. I hope you enjoyed it and even learned a few things.
Posted by Tom Newman. Thanks for reading...