I want to add apple live text support using a scan button. But I know that it is available for iOS 15+ and A12 processors and above. How do I check that in Swift?
Asked
Active
Viewed 344 times
2
-
https://www.hackingwithswift.com/new-syntax-swift-2-availability-checking – koen Mar 14 '22 at 09:59
-
Thanks. That way I can check the iOS version. But is there anyway of checking processor is above A12 or not? – Kushal Mukherjee Mar 14 '22 at 10:05
-
Does this answer your question? [How to know a device is available to use captureTextFromCamera API?](https://stackoverflow.com/questions/69702884/how-to-know-a-device-is-available-to-use-capturetextfromcamera-api) – lorem ipsum Mar 14 '22 at 19:05
1 Answers
3
Don't check for the iOS 15+ and processor A12+, check for the iOS 15's 'Live Text'feature support. Create a helper method with the following check that will return whether the device support live text or not
Sample:
var isSupported = true
if #available(iOS 15.0, *) {
let check = UITextField().canPerformAction(#selector(UIResponder.captureTextFromCamera(_:)), withSender: nil)
isSupported = check
} else {
isSupported = false
}
print(isSupported)
Using the above condition will return false
in the case of the device having iOS 15+ but not having hardware support.

RTXGamer
- 3,215
- 6
- 20
- 29