From e2e06f6f089f59b971ad58bcf3d39634f03089b8 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Mon, 20 Jun 2022 10:16:01 +0200 Subject: [PATCH] mac-syphon: Fix usage of methods deprecated since macOS 11.0 `absolutePathForAppBundleWithIdentifier` and `openFile` have both been deprecated since macOS 11.0. This pr uses the correct modern APIs when OBS is compiled for macOS 11.0 or more recent and falls back to the legacy APIs when either compiled against or run on older macOS versions. --- plugins/mac-syphon/syphon.m | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/plugins/mac-syphon/syphon.m b/plugins/mac-syphon/syphon.m index a34f5eb29..8e132099f 100644 --- a/plugins/mac-syphon/syphon.m +++ b/plugins/mac-syphon/syphon.m @@ -2,6 +2,7 @@ #import #import "syphon-framework/Syphon.h" #include +#include #define LOG(level, message, ...) \ blog(level, "%s: " message, obs_source_get_name(s->source), \ @@ -621,7 +622,19 @@ static inline NSString *get_inject_application_path() { static NSString *ident = @"zakk.lol.SyphonInject"; NSWorkspace *ws = [NSWorkspace sharedWorkspace]; +#if (__MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0) + if (@available(macOS 11.0, *)) { + NSURL *url = [ws URLForApplicationWithBundleIdentifier:ident]; + return [url absoluteString]; + } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + return [ws absolutePathForAppBundleWithIdentifier:ident]; +#pragma clang diagnostic pop + } +#else return [ws absolutePathForAppBundleWithIdentifier:ident]; +#endif } static inline bool is_inject_available_in_lib_dir(NSFileManager *fm, NSURL *url) @@ -865,7 +878,24 @@ static void show_syphon_license_internal(void) return; NSWorkspace *ws = [NSWorkspace sharedWorkspace]; + +#if (__MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0) + if (@available(macOS 11.0, *)) { + NSURL *url = [NSURL + URLWithString: + [NSString + stringWithCString:path + encoding:NSUTF8StringEncoding]]; + [ws openURL:url]; + } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [ws openFile:@(path)]; +#pragma clang diagnostic pop + } +#else [ws openFile:@(path)]; +#endif bfree(path); }