From fc18a171a7a4595fe6f4d5770350a14792786bb4 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sun, 19 Sep 2021 11:54:53 +0300 Subject: [PATCH 1/2] Handle Xcode-specific debug arguments on startup --- UI/NativeApp.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 6a526125c1..3f498b2494 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -612,6 +612,13 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch for (int i = 1; i < argc; i++) { if (argv[i][0] == '-') { +#if defined(__APPLE__) + // On Apple system debugged executable may get -NSDocumentRevisionsDebugMode YES in argv. + if (!strcmp(argv[i], "-NSDocumentRevisionsDebugMode") && argc - 1 > i) { + i++; + continue; + } +#endif switch (argv[i][1]) { case 'd': // Enable debug logging From eb89c9be1ed8e139e02fcd288a4f1e0ff3e871e0 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sun, 19 Sep 2021 12:26:55 +0300 Subject: [PATCH 2/2] Fix garbled log output in Xcode terminal --- Common/ConsoleListener.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Common/ConsoleListener.cpp b/Common/ConsoleListener.cpp index de957012a3..7a3ebd92d1 100644 --- a/Common/ConsoleListener.cpp +++ b/Common/ConsoleListener.cpp @@ -69,6 +69,10 @@ ConsoleListener::ConsoleListener() : bHidden(true) bUseColor = false; #elif defined(_MSC_VER) bUseColor = false; +#elif defined(__APPLE__) + // Xcode builtin terminal used for debugging does not support colours. + // Fortunately it can be detected with a TERM env variable. + bUseColor = isatty(fileno(stdout)) && getenv("TERM") != NULL; #else bUseColor = isatty(fileno(stdout)); #endif