Import LocalAuthentification.framework crashes on iOS 7.1

Have a problem with usage of LocalAuthentication and support iOS 7.0

when I’m trying to

  • sqlite ios : attempt to write a readonly database
  • Realm.objects() returns empty objects
  • How to automatically convert Manual Retain-Release code to ARC?
  • iOS AVFoundation - Show a time display over a video and export
  • Core Data managed object context design recommendation
  • NSData cannot retrive image from internet anymore
  • import LocalAuthentication
    

    I’m getting crash if target iOS version is less than 8.0.

    I tried to mark LocalAuthentication.framework as optional in the build phases and check class availability by calling:

    var isTouchIDSupported: Bool {
            if let contextClass: AnyClass = NSClassFromString("LAContext") {
                return LAContext().canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: nil)
            }
            return false
        }
    

    it do not crash if I comment LAContext() string like:

    var isTouchIDSupported: Bool {
                if let contextClass: AnyClass = NSClassFromString("LAContext") {
                    //return LAContext().canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: nil)
                }
                return false
    

    }

    it crashes at the first seconds the app is launches if I accessing the any of LA class (LAContext for instance) in any place of my code. What I’m doing wrong here?

    Console log for this crash:

    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
    

    4 Solutions Collect From Internet About “Import LocalAuthentification.framework crashes on iOS 7.1”

    LocalAuthentication.framework is available from iOS 8.0. [ iOS Frameworks ]

    To avoid the crash in iOS 7, go to ‘Project Targets’ -> ‘Build Phases’ -> ‘Link Binary with Libraries’ -> set LocalAuthentication.framework’s status to ‘Optional’

    This seems to be a bug in the simulator.
    Do not choose iPhone 5s (7.1).
    If you use iPhone 5 (7.1) and mark the LocalAuthentification.framework as Optional it works. (Link Framework Automatically to NO as well)

    Same problem for iPad Air (7.1), but you can use the Resizable iPad/iPhone option, which works.

    First I marked LocalAuthentification.framework as Optional
    changed “Link Framework Automatically” to NO
    then simple check before access class in code:

    - (BOOL)isTouchIDSupported
    {
        if (NSClassFromString(@"LAContext")) {
            return [self.context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil];
        }
        return false;
    }
    

    Works fine for me, hope that will help somebody

    Try conditionally importing the LocalAuthentication framework and all associated code with pre-processor directives. You’ll then be able to run iOS 7.x simulators and devices through Xcode.