У меня странный сбой при вызове getAllCookies()
Сбой воспроизводится только на реальном устройстве с iOS 11.3.1.На симуляторе работает нормально.
let httpCookieStore = WKWebsiteDataStore.default().httpCookieStore
httpCookieStore.getAllCookies { (cookies) in
}
Сбой в консоли Xcode говорит:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL length]: unrecognized selector sent to instance 0x10fc42790'
Сбой на Crashlytics:
Fatal Exception: NSInvalidArgumentException
-[NSURL length]: unrecognized selector sent to instance 0x1c4466d00
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x18105ed8c __exceptionPreprocess
1 libobjc.A.dylib 0x1802185ec objc_exception_throw
2 CoreFoundation 0x18106c098 __methodDescriptionForSelector
3 CoreFoundation 0x1810645c8 ___forwarding___
4 CoreFoundation 0x180f4a41c _CF_forwarding_prep_0
5 CFNetwork 0x1817a8e44 _CFStringGetOrCreateCString
6 CFNetwork 0x181799a54 CompactHTTPCookieWithData::CompactHTTPCookieWithData(__CFDictionary const*)::PropDecanter::getEnumeratedString(unsigned int)
7 CFNetwork 0x181798fb4 Decanter::decant(__CFAllocator const*)
8 CFNetwork 0x18179956c CompactHTTPCookieWithData::CompactHTTPCookieWithData(__CFDictionary const*)
9 CFNetwork 0x18164f8b0 CFHTTPCookieCreateWithProperties
10 CFNetwork 0x18171fe58 -[NSHTTPCookie initWithProperties:]
11 CFNetwork 0x18171fe24 +[NSHTTPCookie cookieWithProperties:]
12 WebKit 0x190cdc598 WTF::Function<void (WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&)>::CallableWrapper<-[WKHTTPCookieStore getAllCookies:]::$_0>::call(WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&)
13 WebKit 0x190b292ac WebKit::GenericCallback<WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&>::performCallbackWithReturnValue(WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&)
14 WebKit 0x190b291b4 WebKit::WebCookieManagerProxy::didGetCookies(WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&, WebKit::CallbackID)
15 WebKit 0x190b2bb08 void IPC::handleMessage<Messages::WebCookieManagerProxy::DidGetCookies, WebKit::WebCookieManagerProxy, void (WebKit::WebCookieManagerProxy::*)(WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&, WebKit::CallbackID)>(IPC::Decoder&, WebKit::WebCookieManagerProxy*, void (WebKit::WebCookieManagerProxy::*)(WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&, WebKit::CallbackID))
16 WebKit 0x190a0a5bc IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&)
17 WebKit 0x190a5e3c0 WebKit::NetworkProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&)
18 WebKit 0x1909cd8ec IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)
19 WebKit 0x1909d02f4 IPC::Connection::dispatchOneMessage()
20 JavaScriptCore 0x188663e98 WTF::RunLoop::performWork()
21 JavaScriptCore 0x188664158 WTF::RunLoop::performWork(void*)
22 CoreFoundation 0x181007404 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
23 CoreFoundation 0x181006c2c __CFRunLoopDoSources0
24 CoreFoundation 0x18100479c __CFRunLoopRun
25 CoreFoundation 0x180f24da8 CFRunLoopRunSpecific
26 GraphicsServices 0x182f07020 GSEventRunModal
27 UIKit 0x18af0578c UIApplicationMain
28 NAKD-InHouseProd 0x100164ea4 main (AppDelegate.swift:13)
29 libdyld.dylib 0x1809b5fc0 start
Асинхронный вызов getAllCookies в главном потоке , не решает проблему.