Skip to content

OpenURL doesn't work on macOS #440

Description

@freak4pc

Description

Hey, I'm not sure if you're aware (because I assume native macOS devs are rarer compared to iOS ones), but it seems the OpenURL Dependency is a no-op in macOS. I'm not entirely sure why but a quick repro and video:

Repro is a vanilla SwiftUI project wit only swift-dependencies and the following code:

struct ContentView: View {
    @Dependency(\.openURL) private var depOpenURL
    @Environment(\.openURL) private var envOpenURL
    
    var body: some View {
        VStack {
            Button("Open via @Dependency") {
                Task { await depOpenURL(URL(string: "https://riverside.fm")!) }
            }
            Button("Open via @Environment") {
                envOpenURL(URL(string: "https://riverside.fm")!)
            }
        }
        .padding(40)
    }
}
openurl-mac.mov

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

Dependencies version information

No response

Destination operating system

No response

Xcode version information

No response

Swift Compiler version information

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions