From 6f9c468f26ddb60e29be2139397bfaf3b30eab1e Mon Sep 17 00:00:00 2001 From: "Ngo Iok Ui (Wu Yu Wei)" Date: Tue, 11 Jan 2022 14:57:42 +0800 Subject: [PATCH] The `cocoa` crate links to AppKit, which made the symbol `CGDisplayCreateUUIDFromDisplayID` from ApplicationServices/ColorSync (which AppKit uses internally) available to us on macOS 10.8 to 10.13. (#275) However, this does not work on macOS 10.7 (where AppKit does not link to ColorSync internally). Instead of relying on this, we should just link to ApplicationServices directly. --- .changes/mac-link.md | 6 ++++++ src/platform_impl/macos/ffi.rs | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .changes/mac-link.md diff --git a/.changes/mac-link.md b/.changes/mac-link.md new file mode 100644 index 000000000..35c603165 --- /dev/null +++ b/.changes/mac-link.md @@ -0,0 +1,6 @@ +--- +"tao": patch +--- + +Fix linking to the `ColorSync` framework on macOS 10.7, and in newer Rust versions. + diff --git a/src/platform_impl/macos/ffi.rs b/src/platform_impl/macos/ffi.rs index ba195bfd2..26958aafa 100644 --- a/src/platform_impl/macos/ffi.rs +++ b/src/platform_impl/macos/ffi.rs @@ -168,9 +168,18 @@ pub const IO8BitOverlayPixels: &str = "O8"; pub type CGWindowLevel = i32; pub type CGDisplayModeRef = *mut libc::c_void; +// `CGDisplayCreateUUIDFromDisplayID` comes from the `ColorSync` framework. +// However, that framework was only introduced "publicly" in macOS 10.13. +// +// Since we want to support older versions, we can't link to `ColorSync` +// directly. Fortunately, it has always been available as a subframework of +// `ApplicationServices`, see: +// https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html#//apple_ref/doc/uid/TP40001067-CH210-BBCFFIEG +// +// TODO: Remove the WINIT_LINK_COLORSYNC hack, it is probably not needed. #[cfg_attr( not(use_colorsync_cgdisplaycreateuuidfromdisplayid), - link(name = "CoreGraphics", kind = "framework") + link(name = "ApplicationServices", kind = "framework") )] #[cfg_attr( use_colorsync_cgdisplaycreateuuidfromdisplayid,