Search code examples
iosbackwards-compatibility

How can I achieve backward compatibility from iOS 10 to iOS 8?


The app I developed (with Swift 3 and xcode 8) is ready for iOS 10, but my boss wants it to work with iOS 8 because he has an iPhone with 8.2: when I plugged his iPhone to my Mac and started to build the project, it failed because some features are available only on iOS 9.0 or higher.

I did some research and came across some options, but since I'm a beginner I don't know what would be better. Let me share them with you:

  1. rewrite the whole app with Objective-C: I think the less convenient, since I never studied this language and my boss wants the app to be uploaded to the store as soon as possible;
  2. call Obj-C code from Swift for iOS 8 needs;
  3. upload the app anyway: I managed to modify the app and make it compatible with iOS 9, do you know any recommendation or proposal from Apple to not develop app for too much old iOS versions so that I can convince my boss to not obsess over this matter? 87% of devices are using iOS 10 so we would not cut off too many people;
  4. upload the app AND add iOS 8.0 compatibility in a future update: can I change iOS target in next updates?
  5. use Appcelerator or React Native.

Solution

  • The best solution would be to check the iOS version programatically and only call the problematic methods if the user's phone actually supports them. Otherwise keep that functionality hidden from the user.

    This is how you can check iOS version from code:

    if #available(iOS 9, *) {
        // iOS 9 Swift code
    } else {
       //Hide the methods from the users on older OS versions
    }
    
    1. That wouldn't work, since most system APIs are not language dependent. If a certain API/feature was only added in a certain iOS version, that requirement stays the same regardless of whether you use Objective-C or Swift.

    2. Same as 1.

    3. This is a feasible option of course.

    4. AFAIK, you can change the target iOS version in a later update.

    5. If you want to achieve a functionality that uses an API which was only introduced in iOS9, even hybrid frameworks need that iOS version if they use built-in iOS APIs.