From 4900f9876796eb80118ccf6e3bb1a3fcdb3ab291 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Tue, 30 Sep 2025 09:20:09 -0700 Subject: [PATCH 1/3] fix: symbol loader log to system console to not confuse terminal output --- NativeScript/runtime/SymbolLoader.mm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/NativeScript/runtime/SymbolLoader.mm b/NativeScript/runtime/SymbolLoader.mm index cd67b7b1..7d4f85e9 100644 --- a/NativeScript/runtime/SymbolLoader.mm +++ b/NativeScript/runtime/SymbolLoader.mm @@ -2,9 +2,17 @@ #include "SymbolLoader.h" #include "Helpers.h" #include +#include namespace tns { +// Unified logging: create a dedicated log for the SymbolLoader +static os_log_t ns_symbolloader_log() { + // Function-local static initialization is thread-safe in C++11+. + static os_log_t log = os_log_create("@nativescript/ios", "SymbolLoader"); + return log; +} + class SymbolResolver { public: virtual void* loadFunctionSymbol(const char* symbolName) = 0; @@ -101,7 +109,7 @@ virtual bool load() override { if (CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)bundleUrl)) { resolver = std::make_unique(bundle); } else { - NSLog(@"NativeScript could not load bundle %s\n", bundleUrl.absoluteString.UTF8String); + os_log_error(ns_symbolloader_log(), "NativeScript could not load bundle %{public}s", bundleUrl.absoluteString.UTF8String); } } else if (module->libraries->count == 1) { if (module->isSystem()) { @@ -110,10 +118,10 @@ virtual bool load() override { NSString* libraryPath = [NSString stringWithFormat:@"%@/lib%s.dylib", libsPath, module->libraries->first()->value().getName()]; if (void* library = dlopen(libraryPath.UTF8String, RTLD_LAZY | RTLD_LOCAL)) { - NSLog(@"NativeScript loaded library %s\n", libraryPath.UTF8String); + os_log_info(ns_symbolloader_log(), "NativeScript loaded library %{public}s", libraryPath.UTF8String); resolver = std::make_unique(library); } else if (const char* libraryError = dlerror()) { - NSLog(@"NativeScript could not load library %s, error: %s\n", libraryPath.UTF8String, libraryError); + os_log_error(ns_symbolloader_log(), "NativeScript could not load library %{public}s, error: %{public}s", libraryPath.UTF8String, libraryError); } } } From 6655aca019f2dcc8754b676f427c03231de410d1 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Tue, 30 Sep 2025 12:17:05 -0700 Subject: [PATCH 2/3] chore: cleanup --- NativeScript/runtime/SymbolLoader.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NativeScript/runtime/SymbolLoader.mm b/NativeScript/runtime/SymbolLoader.mm index 7d4f85e9..336f8763 100644 --- a/NativeScript/runtime/SymbolLoader.mm +++ b/NativeScript/runtime/SymbolLoader.mm @@ -43,7 +43,7 @@ virtual bool load() override { CFErrorRef error = nullptr; bool loaded = CFBundleLoadExecutableAndReturnError(this->_bundle, &error); if (error) { - NSLog(@"%s", [[(NSError*)error localizedDescription] UTF8String]); + os_log_error(ns_symbolloader_log(), "%{public}s", [[(NSError*)error localizedDescription] UTF8String]); } return loaded; @@ -109,7 +109,7 @@ virtual bool load() override { if (CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)bundleUrl)) { resolver = std::make_unique(bundle); } else { - os_log_error(ns_symbolloader_log(), "NativeScript could not load bundle %{public}s", bundleUrl.absoluteString.UTF8String); + os_log_debug(ns_symbolloader_log(), "NativeScript could not load bundle %{public}s", bundleUrl.absoluteString.UTF8String); } } else if (module->libraries->count == 1) { if (module->isSystem()) { @@ -118,10 +118,10 @@ virtual bool load() override { NSString* libraryPath = [NSString stringWithFormat:@"%@/lib%s.dylib", libsPath, module->libraries->first()->value().getName()]; if (void* library = dlopen(libraryPath.UTF8String, RTLD_LAZY | RTLD_LOCAL)) { - os_log_info(ns_symbolloader_log(), "NativeScript loaded library %{public}s", libraryPath.UTF8String); + os_log_debug(ns_symbolloader_log(), "NativeScript loaded library %{public}s", libraryPath.UTF8String); resolver = std::make_unique(library); } else if (const char* libraryError = dlerror()) { - os_log_error(ns_symbolloader_log(), "NativeScript could not load library %{public}s, error: %{public}s", libraryPath.UTF8String, libraryError); + os_log_debug(ns_symbolloader_log(), "NativeScript could not load library %{public}s, error: %{public}s", libraryPath.UTF8String, libraryError); } } } From fb83172f455be9d3b843a22513b9bb26ea25c458 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Tue, 30 Sep 2025 15:20:29 -0700 Subject: [PATCH 3/3] chore: cleanup --- NativeScript/runtime/SymbolLoader.mm | 3 --- 1 file changed, 3 deletions(-) diff --git a/NativeScript/runtime/SymbolLoader.mm b/NativeScript/runtime/SymbolLoader.mm index 336f8763..66672b55 100644 --- a/NativeScript/runtime/SymbolLoader.mm +++ b/NativeScript/runtime/SymbolLoader.mm @@ -108,8 +108,6 @@ virtual bool load() override { NSURL* bundleUrl = [NSURL URLWithString:frameworkPathStr relativeToURL:baseUrl]; if (CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)bundleUrl)) { resolver = std::make_unique(bundle); - } else { - os_log_debug(ns_symbolloader_log(), "NativeScript could not load bundle %{public}s", bundleUrl.absoluteString.UTF8String); } } else if (module->libraries->count == 1) { if (module->isSystem()) { @@ -118,7 +116,6 @@ virtual bool load() override { NSString* libraryPath = [NSString stringWithFormat:@"%@/lib%s.dylib", libsPath, module->libraries->first()->value().getName()]; if (void* library = dlopen(libraryPath.UTF8String, RTLD_LAZY | RTLD_LOCAL)) { - os_log_debug(ns_symbolloader_log(), "NativeScript loaded library %{public}s", libraryPath.UTF8String); resolver = std::make_unique(library); } else if (const char* libraryError = dlerror()) { os_log_debug(ns_symbolloader_log(), "NativeScript could not load library %{public}s, error: %{public}s", libraryPath.UTF8String, libraryError);