How to programmatically check support of ‘Face Id’ and ‘Touch Id’

I’ve been struggling to get this to work and found that I needed to use a single instance of the LAContext and needed to call the LAContextInstance.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) before getting the biometryType. Here is my final code with support for older iOS versions: import LocalAuthentication static func biometricType() -> BiometricType { let authContext = … Read more

Simultaneous accesses to 0x1c0a7f0f8, but modification requires exclusive access error on Xcode 9 beta 4

I think this ‘bug’ may be a Swift 4 “feature”, specifically something they call “Exclusive access to Memory”. Check out this WWDC video. Around the 50-minute mark, the long-haired speaker explains it. https://developer.apple.com/videos/play/wwdc2017/402/?time=233 You could try turning the thread sanitizer off in your scheme settings if you’re happy to ignore it. However, the debugger is … Read more

Use Xcode 8 with iOS 11

As of now this is only for Debugging on iOS device, not Simulator Xcode 8 could not support unless you have the DeviceSupport folder for the iOS 11 version. You can download a Xcode 9 beta (latest Xcode 9) or get an DeviceSupport folder from other user. Simply copy it to your folder or create … Read more

UISearchController iOS 11 Customization

I just found out how to set them: (with some help of Brandon and Krunal, thanks!) The “Cancel” text: searchController.searchBar.tintColor = .white The search icon: searchController.searchBar.setImage(UIImage(named: “my_search_icon”), for: UISearchBarIcon.search, state: .normal) The clear icon: searchController.searchBar.setImage(UIImage(named: “my_search_icon”), for: UISearchBarIcon.clear, state: .normal) The search text: UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white] The placeholder: UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).attributedPlaceholder = NSAttributedString(string: “placeholder”, … Read more

Use the increased navigation-bar title in iOS 11

The only change done to UINavigationBar API for iOS 11 is prefersLargeTitles. Documentation here: https://developer.apple.com/documentation/uikit/uinavigationbar/ You can do it to your own apps with one small change: check “Prefers Large Titles” for your navigation bar in IB, or if you prefer to do it in code using: navigationController?.navigationBar.prefersLargeTitles = true If you need to change … Read more

iOS 11 SearchBar in NavigationBar

There’s a new searchController property on navigationItem in iOS 11. https://developer.apple.com/documentation/uikit/uinavigationitem/2897305-searchcontroller Use like this… if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { // Fallback on earlier versions navigationItem.titleView = searchController?.searchBar } In Objective-C the if statement looks like this: if (@available(iOS 11.0, *)) { On iOS 11, if you don’t set navigationItem.hidesSearchBarWhenScrolling … Read more