diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index b48dd441146d7..21216674e7fe7 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -48,13 +48,15 @@ impl Plugin for WinitPlugin { #[cfg(target_arch = "wasm32")] app.add_plugin(web_resize::CanvasParentResizePlugin); let event_loop = EventLoop::new(); - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "macos")))] let mut create_window_reader = WinitCreateWindowReader::default(); - #[cfg(target_os = "android")] + #[cfg(any(target_os = "android", target_os = "ios", target_os = "macos"))] let create_window_reader = WinitCreateWindowReader::default(); // Note that we create a window here "early" because WASM/WebGL requires the window to exist prior to initializing // the renderer. - #[cfg(not(target_os = "android"))] + // And for ios and macos, we should not create window early, all ui related code should be executed inside + // UIApplicationMain/NSApplicationMain. + #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "macos")))] handle_create_window_events(&mut app.world, &event_loop, &mut create_window_reader.0); app.insert_resource(create_window_reader) .insert_non_send_resource(event_loop);