使用 LocalAuthentication 有问题并支持 iOS 7.0
当我试图
import LocalAuthentication
如果目标 iOS 版本低于 8.0,我会崩溃。
我试图在构建阶段将LocalAuthentication.framework标记为可选,并通过调用检查类可用性:
var isTouchIDSupported: Bool {
if let contextClass: AnyClass = NSClassFromString("LAContext") {
return LAContext().canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: nil)
}
return false
}
如果我评论 LAContext() 字符串,它不会崩溃:
var isTouchIDSupported: Bool {
if let contextClass: AnyClass = NSClassFromString("LAContext") {
//return LAContext().canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: nil)
}
return false
}
如果我在代码的任何位置访问任何 LA 类(例如 LAContext),它会在应用程序启动的第一秒崩溃。我在这里做错了什么?
此崩溃的控制台日志:
dyld: Symbol not found: _objc_isAuto
Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/lib/libobjc.A.dylib
in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation