Skip to content

Commit 007bc57

Browse files
committed
Fix CGDisplayCreateUUIDFromDisplayID linking (again)
See also #1626. 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. 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.
1 parent 438d286 commit 007bc57

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Unreleased
22

33
- On X11, add mappings for numpad comma, numpad enter, numlock and pause.
4+
- Fix linking to the `ColorSync` framework on macOS 10.7, and in newer Rust versions.
45

56
# 0.26.0 (2021-12-01)
67

src/platform_impl/macos/ffi.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,18 @@ pub const IO8BitOverlayPixels: &str = "O8";
165165
pub type CGWindowLevel = i32;
166166
pub type CGDisplayModeRef = *mut c_void;
167167

168+
// `CGDisplayCreateUUIDFromDisplayID` comes from the `ColorSync` framework.
169+
// However, that framework was only introduced "publicly" in macOS 10.13.
170+
//
171+
// Since we want to support older versions, we can't link to `ColorSync`
172+
// directly. Fortunately, it has always been available as a subframework of
173+
// `ApplicationServices`, see:
174+
// https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html#//apple_ref/doc/uid/TP40001067-CH210-BBCFFIEG
175+
//
176+
// TODO: Remove the WINIT_LINK_COLORSYNC hack, it is probably not needed.
168177
#[cfg_attr(
169178
not(use_colorsync_cgdisplaycreateuuidfromdisplayid),
170-
link(name = "CoreGraphics", kind = "framework")
179+
link(name = "ApplicationServices", kind = "framework")
171180
)]
172181
#[cfg_attr(
173182
use_colorsync_cgdisplaycreateuuidfromdisplayid,

0 commit comments

Comments
 (0)