简体   繁体   中英

Will "Sign in With Apple" allow apps to be backward compatible with iOS 12 and lower?

Does implementing the new Sign in With Apple feature make an app incompatible with iOS 12 and below, similar to SwiftUI? Will it be possible to compile an app which has to import AuthenticationServices on something like XCode 10 ?

Sign in with Apple itself doesn't make the whole app incompatible with iOS 12 and earlier (the same is for SwiftUI).

But when you need to support this kind of feature (which is available starting iOS 13) you'll need to use @available(iOS 13.0, *) attribute and if #available(iOS 13.0, *) checks to conditionally disable support of those features. Otherwise you'll have compilation errors and/or crashes on devices running older versions of iOS.

If you need to support Sign in with Apple on earlier versions of iOS (as well as non-iOS platform), as mentioned by Apple Staff, you should use Sign in with Apple JS framework.

For you second question, as @Paulw11 mentioned, the answer is No , since Xcode 10 doesn't include iOS 13 SDK.

If you want backward compatibility I suggest avoiding using CryptoKit for sha256 encryption. You can use this String extension importing CommonCrypto instead CryptoKit.

import CommonCrypto

extension String {
   var sha256: String {
       let data = Data(utf8)
       var hash = [UInt8](repeating: 0,  count: Int(CC_SHA256_DIGEST_LENGTH))

       data.withUnsafeBytes { buffer in
           _ = CC_SHA256(buffer.baseAddress, CC_LONG(buffer.count), &hash)
       }

       return hash.map { String(format: "%02hhx", $0) }.joined()
   }
}

I already tried to use #if canImport(CryptoKit) for conditional import and set -weak_framework CryptoKit in Other Linker Flags but still crashing for iOS12 and below. So far the only way to make it work is avoiding importing CryptoKit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM