PhoneGap in iOS 6

September 21, 2012 // Tagged in: technology, software, mobile, iOS

Update 9/27:  This post relates to PhoneGap 2.0. 2.1 appears to have fixed a number of iOS 6 compatibility issues, and I recommend upgrading.

Today I upgraded my Xcode to 4.5, which now builds apps against the iOS 6 sdk. This included many breakages to my projects that I had to fix, and a couple to my apps themselves.

The two biggest problems were:

  1. Apple Mach-O Linker Error. Linker command failed with exit code 1. File is universal but does not contain a(n) armv7s slice.
  2. The apps failing to work properly in landscape mode. (The status bar would load landscape, but the webview would load portrait, and never rotate.

To Fix problem 1, I simply had to navigate to Project > Build Settings and change Build Active Architecture Only to "Yes".

To Fix problem 2, I had to change some of the PhoneGap base code. I found the solution here.

In Classes > AppDelegate.m change the line:

[self.window addSubview:self.viewController.view];

to

self.window.rootViewController = self.viewController;

and in Classes > MainViewController.m, add the line:

 self.webView.frame = CGRectMake ( 0, 20, self.view.frame.size.width, self.view.frame.size.height-20);

right after

  [super viewDidLoad];

That's it - this makes the WebView inherit from the root view controller instead of a subview, and the additional line allows the webview frame to load without being cut off by the status bar.