Sunday, 18 August 2013

Writing iOS7 code that compiles against iOS 6 Base SDK

Writing iOS7 code that compiles against iOS 6 Base SDK

We have an iOS app on-sale now, and we're developing the iOS 7 version on
XCode 5 DP using the same code base.
We would really to release an update right now for existing iOS 5/6
customers but, of course, when we re-load the project into XCode 4, it
complains about non-existing properties since the Base SDK then becomes
iOS6, not 7:
// Only run this bit on iOS 7
if ([self respondsToSelector:@selector(setFooForExtendedLayout:)])
{
self.fooForExtendedLayout = UIFooEdgeLeft | UIFooEdgeRight;
}
float bottomOffset = 0;
// Only run this bit on iOS 7, else leave bottomOffset as 0
if ([self.hostController respondsToSelector:@selector(bottomLayoutFoo)])
bottomOffset = self.hostController.bottomLayoutFoo.length;
(obfuscated to avoid breaking NDA)
XCode Errors:
Property 'fooForExtendedLayout' not found on object of type
'UIViewController *'
Use of undeclared identifier 'UIFooEdgeLeft'
Use of undeclared identifier 'UIFooEdgeRight'
Property 'bottomLayoutFoo' not found on object of type 'UIViewController *'
It would be a pain to comment out this new code. What is the correct way
to re-write it to be compatible with both the old and new Base SDKs, and
does submitting it now (via XCode 4 and built against iOS 6 SDK) risk any
sort of App Store rejection?

No comments:

Post a Comment