From c58caffb86d4397f8b77c3f52887120214b9c3be Mon Sep 17 00:00:00 2001 From: p-x9 <50244599+p-x9@users.noreply.github.com> Date: Fri, 7 Oct 2022 20:53:12 +0900 Subject: [PATCH] fix to export http cookies before stashing container --- Sources/AppContainer/AppContainer.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Sources/AppContainer/AppContainer.swift b/Sources/AppContainer/AppContainer.swift index 673e2f2..4c843f9 100644 --- a/Sources/AppContainer/AppContainer.swift +++ b/Sources/AppContainer/AppContainer.swift @@ -99,6 +99,7 @@ public class AppContainer { } try exportUserDefaults() + exportCookies() try stash() @@ -438,5 +439,16 @@ extension AppContainer { let plistData = try PropertyListSerialization.data(fromPropertyList: dictionary, format: .xml, options: 0) try plistData.write(to: plistUrl) } - +} + +extension AppContainer { + private func exportCookies() { + let cookieStorage: HTTPCookieStorage + if let groupIdentifier = groupIdentifier { + cookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: groupIdentifier) + } else { + cookieStorage = .shared + } + cookieStorage.perform(NSSelectorFromString("_saveCookies")) + } }