Legacy UI with Xcode 5 and iOS 7 SDK

As of February 1st, all new submissions and updates to the App Store need to be compiled using the latest version of Xcode and the latest iOS SDK. This does not mean that your apps must target iOS 7 exclusively, you just need to use the latest build tools (which you were doing already, right?).

For brand new apps, Apple has reported that iOS 7 marketshare is already at 78% so you could just start targeting iOS 7. For existing app however, many have been designed with iOS 6 UI guidelines in mind and can’t just flip a switch to follow the newer iOS 7 design guidelines. If you fall into that second group, here’s a few things you’ll need to do to keep the legacy UI working properly with the latest tools and SDKs.

Deployment Target

If you want to maintain the old look and feel of iOS, you’ll be targeting a lower SDK than 7. This means your tools will use the latest SDK to build the app but the code you’ve written is compatible with earlier versions as well. Select your project and check that the iOS Deployment Target is set the the appropriate version you’d like to target. For example, iOS 5.1 here:

Setting deployment target to latest SDK

Base SDK

As per Apple’s new requirements, you must set the Base SDK in your target Build Settings to Latest iOS as shown here:

Setting Base SDK

This will use the latest SDK you have installed.

Stroryboards and XIBs

To make designing a little easier, your storyboards and xibs should keep their legacy appearance in Xcode. To achieve this, select the File Inspector in each of your storyboards and set the Build for setting to Project Deployment Target and then set the View as setting to iOS 6.1 and earlier. As you can see in the following two screen shots, this will make the UI elements such as navigation bars and tab bars appear as though they were using the older iOS styles instead of the newer iOS 7 style:

iOS 7 and later

iOS 6.1 and earlier

One other thing you may need to adjust is the navigation bar’s translucent setting. I’ve found that sometimes your view will partially slide under the navigation bar if this is left checked (which is the default in the iOS 7 SDK). The easiest way to change them all is to enter “navigation bar” as the filter text in the storyboard’s Document Outline and then select each one and manually uncheck the Translucent box in the Attributes Inspector.

Disable translucent bars

User Defaults and main.m

One last thing to do is force the device to use the legacy UI elements for your app. This is a bit of a hack that done by setting a special attribute in NSUserDefaults. If you set UIUseLegacyUI to YES, the iOS device will use the legacy UI elements1. The trick is that the default needs to be set before the app runs, so setting it in your app’s delegate isn’t going to work. Instead find your main.m file (this is where your app actually “starts”, and add it right before the call to UIApplicationMain() like so:

int main(int argc, char * argv[])
	@autoreleasepool {
		[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"UIUseLegacyUI"];
		[[NSUserDefaults standardUserDefaults] synchronize];
		return UIApplicationMain(argc, argv, nil, NSStringFromClass([LTAppDelegate class]));

This way the attribute is always set right before the app runs and will be set on the very first run too.

Now if you run your app on an iOS 7 device or in the the iOS 7 simulator, you’ll see that it looks just like it did in iOS 6 and earlier.

That legacy look

  1. Though UIUseLegacyUI this isn’t officially documented by Apple, I have submitted apps successfully using this flag.