Backwards compatibility of Swift for versions back to iOS 5 [duplicate] - ios

This question already has answers here:
Swift with iOS 5 deployment target [duplicate]
(2 answers)
Closed 7 years ago.
I haven't studied Objective-C yet, except some basics. I like backward compatibility, so I would like my iOS app work for example with iPod Touch 3rd Gen. (iOS 5) and the new iPhone 6 (iOS 8) also. In that case do I need to use Swift yet?
Edit: My idea at the moment is to make cheap apps for iOS, Android and Windows Phone for developing countries and others as well. That is why I'm interested in backward compatibility (not Swift development), because there are people who buy used devices and still might be able to buy apps to those devices. When I asked this question I was uncertain how far back I can go with iOS versions.

Swift's min deployment target is iOS 7. So, no, if you want to support iOS 5 (which would be completely nuts IMHO), you'll need to use objective C.
Also, it doesn't look like Apple will remove support for objective C in any near future, so there is no need to switch to Swift anyway, you are still free to decide which language you prefer.

Related

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:
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.

Is there any way to completely turn off an ios device programmatically in xcode? [duplicate]

This question already has an answer here:
How to power iOS device off [duplicate]
(1 answer)
Closed 7 years ago.
I want to make an application that would turn off an iphone at a set time every night;
Absolutely not! (Unless we are talking about a jailbroken app.)
Apple has a very strict sandboxing approach for third party apps. To access the system, you have to use the provided iOS APIs and none of them offers this kind of control.

iOS versions: if I have an app with specific "minor" device required, how can I use benefits of newer devices in the same app?

I have requirements for the iOS app.
Devices that must be supported and iOS versions are listed by the customer.
It is written that the app must support:
- devices: from iPhone 4 and above;
- iOS versions: 7, 8.
I feel myself misled.
As far as I know iPhone 4 is not in the iOS 8 supported devices list.
That's why I have to target to the iOS 7.1.2 - the one that currently supported on all required devices.
How can use benefits of the iOS 8 in this app?
Could you help me with good references that will help me to understand the intricacies of this question?
In short:
Yes, you can but not on the device running with the older version of a system (so you will need conditions for such cases).
Detailed explanation:
If your app has to be compatible with iOS 7 then you can not use iOS 8 features on the system which is older. This is quite obvious, system can not understand commands that haven't been implemented yet. Although you can use in your app API that was revealed in iOS 8 but you have to create, at least, conditions checking agains which system version you run if you want to avoid troubles like app crashes. Quite a good reading for better understanding an issue can be this article. Here you have quite a nice graphic presenting which device supports which version of a system (according to your question about iPhone 4).

Rebuilding existing app with Swift

Do I have to rebuild my existing apps with the Swift language in order to support iOS8 when it will be released and the most of iPhone owners upgrade to this version? If I must rebuild my apps to new standards or not? At moment my apps are running under iOS6.
My main concern is if I have to abandon the iOS6 version or not.
I watched the announcement, but here's a blog to support me :
Matter of fact, Swift code can co-exist with Objective-C...
Developers don’t need to choose between C for Mac development and Objective-C for iOS development because Swift supports both iOS and OS X and can co-exist with C and Objective-C code.
For the time being, Apple plans to support both Swift, Objective-C, and hybrid apps built with both.
No, you do not need to abandon iOS 6 .. although with 89% of devices running iOS 7, you may considering doing it soon ...
No, you will not need to rebuild your apps with Swift. The compiler compiles Objective C and Swift down to the same code to run on your iPhone and both languages can co-exist. Objective C will likely be phased out gradually over a number of years.
If you still wish to switch your existing apps over to Swift, here's a handy migration guide from Apple.

iOS5, iOS4, ... statistics? [duplicate]

This question already has answers here:
Breakdown of iOS versions being used [closed]
(3 answers)
Closed 5 years ago.
I'm looking for usage statistics of Apples iOS. Something like that http://www.w3schools.com/browsers/browsers_stats.asp for browser usage.
Does anyone know a source?
You can go to http://marketshare.hitslink.com/, view mobile browsers by version, then infer the iOS version market share from the version of Mobile Safari being reported. But keep in mind that it's not a direct translation between the two version numbers. Here's the version number translation I've been able to figure out (by seeing which iOS release came out the same month each new Safari version first appeared):
Mobile Safari Version iOS Version
5.1 5.0
5.0 4.2-4.3
4.0 3.0-4.1
3.1 2.x
3.0 1.x
By their metrics, iOS 5.0 is up to 35.61% (of all mobile phone web users) as of February, iOS 4.2-4.3 is down to 21.14%, and 3.0-4.1 is only 2.78%.

Resources