Set cookie in WKWebView in iOS 10: 'httpCookieStore' is only available in iOS 11.0 or newer
I have the following code to set a cookie in WKWebView:
let cookie = HTTPCookie(properties: [ .domain: ".example.com", .path: "/", .name: "name", .value: "value", .secure: "TRUE", .expires: NSDate(timeIntervalSinceNow: 31556952) ])! webView.configuration.websiteDataStore.httpCookieStore.setCookie(cookie)
This is working very well for iOS 11 and above. Unfortunately, this throws an error for iOS 10:
‘httpCookieStore’ is only available in iOS 11.0 or newer
How can I make this Swift code working for iOS 10.