Unresolved import `wry::application::platform::unix`

Hello

I have a function launching a Wry-webview. I launch it in a separate thread, because of this I need to make a EventLoopBuilder like this:

    use wry::application::platform::windows::EventLoopBuilderExtWindows;

    let event_loop: EventLoop<()> = EventLoopBuilder::default()
        .with_any_thread(true) // Necessary because it gets launched in a separate thread
        .build();

This works perfectly on Windows. But I am trying to compile it on MacOS.

    use wry::application::platform::unix::EventLoopBuilderExtUnix;

 let event_loop: EventLoop<()> = EventLoopBuilder::default()
        .with_any_thread(true) // Necessary because it gets launched in a separate thread
        .build();

This yields the error:

error[E0432]: unresolved import `wry::application::platform::unix`
   --> src/ui.rs:355:37
    |
355 |     use wry::application::platform::unix::EventLoopBuilderExtUnix;
    |                                     ^^^^ could not find `unix` in `platform`

wry::application::platform::unix does exist however. How to fix this?

This is a reexport from tao, and if you look in the unix.rs source file of tao you will see:

#![cfg(any(
  target_os = "linux",
  target_os = "dragonfly",
  target_os = "freebsd",
  target_os = "netbsd",
  target_os = "openbsd"
))]

macOS is not on that list, so the unix module does not exist. You would need to use the macos module instead β€”

β€” but what you are trying to achieve cannot be done, so you won't find a matching with_any_thread() option. On macOS, all GUI must be managed from the β€œmain” thread. Instead of trying to put the GUI on a different thread, put the rest of your application on a spawned thread, then let the main thread be the GUI.

1 Like

I decided to make a separate binary for the Wry-webview. That saves some headache.