You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use App Group and would like to use a shared app group container so our App Clip can have the same identity. Currently, this workaround of swizzling various parts of Persistence seems to work but is not ideal.
publicextensionURL{staticvardataDirectory:URL?{letappGroupURL=FileManager.default.containerURL(forSecurityApplicationGroupIdentifier:Constants.appGroupId)letdefaultDirectory=try?FileManager.default.url(for:.documentDirectory, in:.userDomainMask, appropriateFor:nil, create: false)return appGroupURL ?? defaultDirectory
}}extensionFileManager{// Swizzled method@objcprivatefunc swizzled_urls(for directory:FileManager.SearchPathDirectory, in domainMask:FileManager.SearchPathDomainMask)->[URL]{
if Thread.callStackSymbols.joined().contains("Mixpanel"),let dataDirectory =URL.dataDirectory {return[dataDirectory]}returnswizzled_urls(for: directory, in: domainMask)}staticletswizzleURLs:Void={letoriginalSelector= #selector(FileManager.urls(for:in:))letswizzledSelector= #selector(FileManager.swizzled_urls(for:in:))
guard
let originalMethod =class_getInstanceMethod(FileManager.self, originalSelector),let swizzledMethod =class_getInstanceMethod(FileManager.self, swizzledSelector)else{return}method_exchangeImplementations(originalMethod, swizzledMethod)}()}publicextensionUserDefaults{staticletswizzleSuiteName:Void={letoriginalSelector= #selector(UserDefaults.init(suiteName:))letswizzledSelector= #selector(UserDefaults.init(swizzled_init:))
guard let originalMethod =class_getInstanceMethod(UserDefaults.self, originalSelector),let swizzledMethod =class_getInstanceMethod(UserDefaults.self, swizzledSelector)else{return}method_exchangeImplementations(originalMethod, swizzledMethod)}()@objcconvenienceinit?(swizzled_init suiteName:String?){
if suiteName =="Mixpanel"{self.init(suiteName:Constants.appGroupId)}else{self.init(swizzled_init: suiteName)}}}
The text was updated successfully, but these errors were encountered:
IsaiahJTurner
changed the title
Support data sharing with App Groups
Support data sharing with App Groups for App Clips
Nov 13, 2024
We use App Group and would like to use a shared app group container so our App Clip can have the same identity. Currently, this workaround of swizzling various parts of Persistence seems to work but is not ideal.
The text was updated successfully, but these errors were encountered: