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

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:
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;
call Obj-C code from Swift for iOS 8 needs;
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;
upload the app AND add iOS 8.0 compatibility in a future update: can I change iOS target in next updates?
use Appcelerator or React Native.

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
}
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.
Same as 1.
This is a feasible option of course.
AFAIK, you can change the target iOS version in a later update.
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.

To add iOS 8 compatibility you must change the deployment target version to 8.0 and resolve every warning/issue that Xcode give you when you try to build/run.
You will need to use if #available(iOS 9, *) {} code if you use APIs that changed between the versions 8 and 10.

You don’t need to rewrite anything in objective c. For the features that are getting called out, research the iOS 8 compatible way to implement them (if even possible) and add checks in your code for iOS version so that certain blocks only execute for certain os’s. (See technical answers already provided)
But, first show your boss how to update his phone.
Then show your boss that 97% of users are using 9 or 10.
https://developer.apple.com/support/app-store/
Next remind him that the 3% of out of date users are also the 3% least likely to be downloading apps and only part of that 3% are on iOS 8. Many are even more out of date.
Then calculate the number of hours required to support iOS 8. Multiply that by your hourly rate. Then ask your boss if it’s worth $X to expand your app’s user base by, at best,1%.
If he says yes, then go for it.

Related

Which minimum iOS version should my app support if creating BLE app?

I am about to start new application and my customer want to support iOS 5 and iPhone 5 also including all latest range devices. I am using swift and official apple doc saying it supports till iOS 7. My app will going to work based on BLE and location update data and basically its a IOT application.Issue is should i start giving support from iOS 7 or 5 or from 9? I do not have any exact clue why I should not choose iOS 7 version and I should start iOS 9.
You can start by checking the device capability table here:
https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/DeviceCompatibilityMatrix/DeviceCompatibilityMatrix.html
As it states there, the first device compatible with Bluetooth Low Energy is iPhone 4s.
With that in mind you could possibly support the first iOS version which supports iPhone 4s, from here it is iOS 5. As others mentioned Core Bluetooth was introduced a bit later.
Now you should understand that supporting all versions starting from such an old OS version will introduce A LOT of work. Then you have 2 questions which we cannot answer:
Do you want to do that work?
Is your customer willing to pay for it?
As for link for your customer I guess you could use this:
https://mixpanel.com/trends/#report/ios_10
I would say that Mixpanel is quite a big company which tracks iOS distribution numbers pretty precise.
The facetious reply - nonetheless a valid one - is to find another client.
A more rational reply is to speak reasonably to your client with confidence and knowledge of history.
1 iOS underwent a major UI change with iOS 7, what's to be gained by supporting something older?
2 If the device in question is actually running iOS 5 today it probably cannot use iOS 8 or above.
3 As you said, Swift will not run on a device unless it's iOS 7 and above.
4 The historical adoption rate for the next version of iOS - since I believe the start of history in 2007 - is well above 80% in the first year and 90% the year after.
Combining these things, you have several arguments for this client. (And yes, this question and/or answer likely belongs in the freelancing site.)
1 Why the need for iOS 5?
Give them the current numbers of how many devices currently still run iOS 5. Have them defend this reason, or else find another client.
2 If the client is "closed", meaning they aren't looking to market your code, then why are they using devices running iOS 5?
Again, the only reason to use that old a version - understanding that a device running iOS 5 is old enough yet likely new enough to at least run iOS 7 - is that they are cash-strapped. Frankly, that's a client I'd run from. Quick.
3 There's two likely reason for this request. (a) They are testing you to see how you reply. (b) They are not as informed as you about the current state of the iOS market.
Let's take the the latter one first. Be informed and knowledgable and stick with the facts. Use the arguments I lined out above. If they aren't convinced - you probably need to drop them as a client. While the "customer rules", nobody wants a client you cannot reason with.
As for the former - the client is testing you?
Again, give them the facts - you can support iOS5, but with limitations - later versions of iOS may not run those devices, later features introduced in iOS (particularly UI things like auto layout, UICollectionViews, etc.) mean extreme complications in the code base... adding both time and money, and it needs to be written in Objective-C.
iOS 5?! Right now iOS 9 has 92% of active devices so you should definitely choose it or even iOS 10.
For BLE as you mentioned iOS 7 and iPhone 4S is minimum.
You can see from the Documentation that Core Bluetooth was introduced in iOS 5, so you can target that version and still have BLE support but only in Objective-C
However, there will be a number of other enhancements in iOS that you will not be able to take advantage of and this will make development more difficult Andre therefore more expensive.
iOS 5 is very old and probably represents a very small percentage of devices.

Things to be considered while upgrading the iOS app

There is an iOS app developed in iOS 4.3. Now I want to upgrade this app to iOS 9 and later. I can able to run the application even on iOS 10 devices. But there are lot of deprecated warnings regarding the latest SDK.
The main reason I'm posting this question is, while upgrading the app from lower version to latest version, what are the action items to be consider to make the application perfect on latest SDK?
Here are few points I've noted,
Clear all deprecated warning.
Do analyser for memory leak.
Enable ARC if not enabled yet.
Proper unit testing.
Please advice me some more point.
Note: I'm not converting the app to Swift, using Objective-C only.
Update: I know the basic things like changing the deployment targets, update the used libraries / Frameworks to latest one, etc., I want more high level points those features are available in latest SDK comparing with lower one.
Thanks
Here are some more points you have to consider for latest iOS support,
Change deployment target in general setting.
Check for device compatibility for design constraint. There are new devices.
Change the version of your app in general settings.
If there are any functionality for touch event than check if it is possible to implement 3D touch for newer device.
And go for proper testing of functionality and design.
Hope it will help you.

Will iOS Application created in XCode 7.2 with SDK 9.2 be compatible with iOS 6 in iPhone 4?

If i create an iOS application in XCode 7.2 with SDK 9.2, will that application work in iOS 6 in iPhone 4?
In general, this is possible - that is where the availability information in the apple documentation comes into play.
You may use iOS 6 as your deployment target and only use the API available on iOS 6.
This will mean your code completion on the current Xcode will suggest unavailable methods and you will be very limited in terms of what the API can do for you.
Also, to cherry pick one of the problems you might run into:
iOS 6 has a whole different approach to authorization for location usage than iOS 9, so you would have to (partly) clutter your code with a lot of version checks to give different implementations for the different versions (and version checks were not available back then). Because, a iOS 9 device will not even ask the user for permissions if you do it the way iOS 6 documentation says you have to do it.
The very fact that you do ask this question might already give away that in general, the answer is
Yes, that can be done with a lot of work that is almost intractable for a single person and in almost all cases not needed.
as the market share of iOS 6 is only a tiny fraction, but in your case, the answer might even be
You will probably fail horribly at some point and should reconsider if this is really necessary. The market share of iOS 6 is really small and you are basically putting in weeks of extra work for basically a hand full of potential users.
Also, as you might have guessed from this (and other answers), if your question is if this works out of the box, the answer is
No.
in general yes or no terms.. yes it is possible.
(Our app spans between 7 and 9)
Supporting ios6 will require a lot of work though since you must take care not to use any features that aren't available on ios6 and iOS sdk6 and iOS sdk9 differ quite a bit :)
I'd consider if it is worth the effort.

Restrict Versions iOS - NO minimum version

Detail: NO is the minimum version
Is there any way I can restrict versions of iOS?
For example, I have developed an application and would like it swirled in iOS versions 7.x.x and iOS 8.1.x. In short, I would avoid the application was installed on the iOS versions 8.0.x.
How come? Currently in iOS 7 works perfectly on iOS 8.1.x also, but on iOS 8.0.x the application presents several problems, including constant crashes.
No it's not possible. Apple only accepts new apps in the App Store which are able to run on the current iOS(iOS 8+ at the moment). They don't care about earlier iOS versions.
Simply said: Apps have to run on the newest iOS version.
Also I'd recommend you to fix the iOS 8 errors instead, because even if you could do that. Over 50% of all iOS users are using iOS 8. That means that your app won't be seen by many users. If you have trouble to resolve your errors, I'm sure there are people, maybe on this website, which will help you.

What does "Available in iOS x.x and later" mean?

What exactly does this mean? I've seen Availability: iOS (6.0 and later) and other version numbers, but I don't think thats exactly what it means. Does it truly mean that its only available with iOS 6 and up? If thats the case, then why is the comparable method for iOS 2.0f and later depreciated? Shouldn't I still be using it when the iOS version is less that 6.0 or the specified availability?
An example is NSTextAlignmentCenter. It specifies that it is Availability: iOS (6.0 and later), but I'm building an app for iOS 4.3 and up. I'm currently performing a check on the iOS version of the device and choosing the text alignment between NSTextAlignmentCenter and UITextAlignmentCenter. To me, this seems odd. Shouldn't it be for iOS SDK 6.0 and later, rather than iOS 6.0 and later?
I know this seems like nitpicking, but it makes a pretty big difference.
I've seen Availability: iOS (6.0 and later) and other version numbers,
but I don't think thats exactly what it means. Does it truly mean that
its only available with iOS 6 and up?
Yes, it truly means only available in iOS 6 and later.
Most of the Apple-provided frameworks that you link into your app are dynamic -- they're not built into your app, but linked in when the app launches. They exist on the device as part of the operating system. That means that making retroactive changes such as adding a new method is somewhere between difficult and impossible. Important changes, such as security fixes, are typically made in minor OS updates. Feature changes to the API are usually reserved for more significant upgrades.
Some changes do happen retroactively. For example, object literals work not just in iOS 6 but also in 5 and (I think) even 4. That's because in the case of object literals, the change is in the compiler, not in the operating system or frameworks. As long as you're using a compiler that understands the object literal syntax, the object code that the compiler emits will be compatible with older systems.
It means what it says. If it says "2.0 and later" then you can safely use it in any app that target SDK 2.0 or later.
It means that you can use it starting from this x.x OS version.
Think about this in following way - each feature including API has initial version on which it's born (x.x). It lives for some time (through several versions) and at some point it becomes old (new features can do the same thing, but better) and it's marked as deprecated. It's still could be used, but it's not recommended anymore. And at some moment this feature/API dies (becomes unsupported).
So, if you plan to support iOS 4.3 and up, you will have to choose features which alive in iOS 4.3 to 6.0 (already born, but aren't dead yet).
It doesn't refer to SDK version - it iOS version. Every version of iOS adds new APIs that it it supports so you can't use an API (like NSTextAlignmentCenter) that don't exist in that version.

Resources