Skip to content
Back

macOS app: OAuth flow doesn’t start

  • 0
  • Apple
Võ Văn Thương
3 Apr, 2026, 04:53

Hi Appwrite team,

I’m integrating the Appwrite Swift SDK into a macOS app and am hitting an environment/runtime issue when starting OAuth.

App architecture • macOS app built on AppKit lifecycle (@main class ​App​Delegate: ​NSApplication​Delegate). • Main UI windows are NSWindow instances that embed SwiftUI content via NSHosting​View. • The sign-in sheet is a SwiftUI view (Auth​Sheet​View) shown inside that hosted window.

At runtime the call logs:

TypeScript
Accessing Environment<OpenURLAction>'s value outside of being installed on a View.  This will always read the default value and will not update.

Questions

  1. Does create​OAuth2​Session internally rely on SwiftUI’s open​URL environment, and does that fail when the view is hosted inside an NSHosting​View under an AppKit lifecycle?
  2. What’s the recommended way to trigger create​OAuth2​Session in a hybrid AppKit + SwiftUI macOS app? • Should we supply a custom Open​URLAction or call an alternative API that works without open​URL? • Is there a configuration flag or parameter to force the SDK to use NSWorkspace​.shared​.open / ASWeb​Authentication​Session on macOS instead of SwiftUI’s environment?

Thanks for any guidance or workarounds. Happy to provide more code or logs if needed.

TL;DR
Problem: OAuth flow not starting in macOS app integrated with Appwrite Swift SDK due to environment/runtime issue when starting OAuth. Solution: The issue might be related to the OAuth2Session relying on SwiftUI's openURL environment, which fails when the view is hosted inside NSHostingView under an AppKit lifecycle. For a hybrid AppKit + SwiftUI macOS app, consider providing a custom OpenURLAction or calling an alternative SDK API that works without openURL. Additionally, check for any configuration flags or parameters to force the SDK to use NSWorkspace.shared.open or ASWebAuthenticationSession on macOS instead of SwiftUI's environment.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more