From a7ba0bea6ee869c3e57c0fdca4165ea2b8c264dd Mon Sep 17 00:00:00 2001 From: David Fuhrmann Date: Sat, 9 Sep 2017 12:43:11 +0200 Subject: [PATCH] Sparkle: Add backwards compatibility with 10.11 SDK for logging 10.11 SDK does not contain the os_log API yet. Code is modified in such a way that it compiles with older SDKs, and falls back to the old implementation even if it runs on 10.12. --- Sparkle/SULog.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Sparkle/SULog.m b/Sparkle/SULog.m index 7faa0a6d..ab417b8f 100644 --- a/Sparkle/SULog.m +++ b/Sparkle/SULog.m @@ -7,15 +7,29 @@ // #include "SULog.h" + #include +#include + +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 #include +#else + +typedef struct os_log_s *os_log_t; +#define os_log_create(subsystem, category) nil + +#define os_log(log, format, ...) +#define os_log_error(log, format, ...) + +#endif + +#include "AppKitPrevention.h" #import "SUOperatingSystem.h" // For converting constants to string literals using the preprocessor #define STRINGIFY(x) #x #define TO_STRING(x) STRINGIFY(x) -#include "AppKitPrevention.h" void SULog(SULogLevel level, NSString *format, ...) { @@ -30,6 +44,9 @@ void SULog(SULogLevel level, NSString *format, ...) NSBundle *mainBundle = [NSBundle mainBundle]; hasOSLogging = [SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 12, 0}]; +#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101200 + hasOSLogging = NO; +#endif if (hasOSLogging) { const char *subsystem = SPARKLE_BUNDLE_IDENTIFIER;