From 5e37ee44f410ba12090ae0427f8304aa6958f89a Mon Sep 17 00:00:00 2001 From: Guogang Li Date: Wed, 28 May 2025 15:32:07 -0700 Subject: [PATCH] Enable Nearby logger writer for iOS PiperOrigin-RevId: 764442996 --- connections/c/BUILD | 7 ++++++- connections/c/nc.cc | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/connections/c/BUILD b/connections/c/BUILD index cfa2297c..e197a1a0 100644 --- a/connections/c/BUILD +++ b/connections/c/BUILD @@ -52,7 +52,12 @@ cc_library( "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", - ], + ] + select({ + "@platforms//os:platform_ios": [ + "//internal/platform/implementation/apple:logger_writer", + ], + "//conditions:default": [], + }), ) # iOS only. diff --git a/connections/c/nc.cc b/connections/c/nc.cc index 89c2f5ee..882928b2 100644 --- a/connections/c/nc.cc +++ b/connections/c/nc.cc @@ -49,6 +49,9 @@ #include "internal/platform/byte_array.h" #include "internal/platform/file.h" #include "internal/platform/logging.h" +#if TARGET_OS_IOS +#include "internal/platform/implementation/apple/nearby_logger_writer.h" +#endif // TARGET_OS_IOS namespace nearby::connections { class Core; @@ -221,6 +224,12 @@ NcContext* GetContext(NC_INSTANCE instance) { NC_INSTANCE NcCreateService() { NcContext nc_context; +#if TARGET_OS_IOS +#if DEBUG + absl::SetGlobalVLogLevel(1); +#endif // DEBUG + ::nearby::apple::EnableNearbyLoggerWriter(); +#endif // TARGET_OS_IOS #if defined(NC_IOS_SDK) nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(