Hi All,
I have a finder sync extension that passes data back to my main app. It currently writes to a plist file in my group container folder. Since updating to macOS 15, I have been getting this pop-up every time I trigger this writing to the plist after the finder sync extension loads.
This is how I write to the plist from my finder sync extension:
let appGroupDefaults = UserDefaults(suiteName: "group.team_id.Finder-Sync-Extension-Test-Project")
let items = FIFinderSyncController.default().selectedItemURLs()
DispatchQueue.main.async {
let url = items?.first?.absoluteString
var file = items?.first?.lastPathComponent
if let defaults = appGroupDefaults{
defaults.set(url, forKey: "targetURL")
defaults.synchronize()
}
self.showWindow(with: NSExtensionContext())
}
This is how I read the plist from my main app:
if let defaults = UserDefaults(suiteName: "group.team_id.Finder-Sync-Extension-Test-Project") {
defaults.synchronize()
if let clickedUrl = defaults.string(forKey: "targetURL") {
window = NSWindow(contentRect: NSScreen.main?.frame ?? .zero,
styleMask: [.miniaturizable, .closable, .resizable, .titled],
backing: .buffered,
defer: false)
window?.title = "My App"
window?.makeKeyAndOrderFront(nil)
textField.stringValue = clickedUrl
window?.contentView?.addSubview(textField)
}
}
It is fine if this popup happens once and the user's choice gets remembered. I just don't want it to happen every time.
Any help on if this is the correct way to pass data between the finder sync extension and the main app or on how to get macOS to remember the choice of the user would be great.
Thanks, James