From 6856d23a2e0012afcfc20d1033a444f9a73dda3b Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Fri, 20 Mar 2026 23:28:47 -0700 Subject: [PATCH] fix(swift-sdk): resolve BLAuditLogger + BLCrashReporter build errors in ByteLystPlatform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BLAuditLogger is an enum (static API) — cannot be constructed; use .Type reference + configure() - BLCrashReporter is @MainActor — defer construction to start() via Task { @MainActor } --- .../Sources/ByteLystPlatform.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/swift-platform-sdk/Sources/ByteLystPlatform.swift b/packages/swift-platform-sdk/Sources/ByteLystPlatform.swift index 0d0343c0..1e920739 100644 --- a/packages/swift-platform-sdk/Sources/ByteLystPlatform.swift +++ b/packages/swift-platform-sdk/Sources/ByteLystPlatform.swift @@ -35,14 +35,14 @@ public final class ByteLystPlatform { /// Kill switch checker. public let killSwitch: BLKillSwitchClient - /// Crash reporter (MetricKit). - public let crashReporter: BLCrashReporter + /// Crash reporter (MetricKit). Created lazily on MainActor. + public private(set) var crashReporter: BLCrashReporter? /// Keychain access (via bundleId as service). public let keychain: BLKeychainAccessor - /// Audit logger. - public let auditLog: BLAuditLogger + /// Audit logger type (static API — call BLAuditLogger.log()). + public let auditLog: BLAuditLogger.Type = BLAuditLogger.self /// Auth client. public let auth: BLAuthClient @@ -56,10 +56,9 @@ public final class ByteLystPlatform { self.telemetry = BLTelemetryClient(config: config, client: client) self.flags = BLFeatureFlagClient(config: config, client: client) self.killSwitch = BLKillSwitchClient(config: config) - self.crashReporter = BLCrashReporter(productId: config.productId) self.keychain = BLKeychainAccessor(service: config.bundleId) - self.auditLog = BLAuditLogger(productId: config.productId) self.auth = BLAuthClient(config: config, client: client) + BLAuditLogger.configure(fileName: "\(config.productId)_audit_log.json") } /// Test-only initializer that accepts a custom URLSessionConfiguration. @@ -69,10 +68,9 @@ public final class ByteLystPlatform { self.telemetry = BLTelemetryClient(config: config, client: client) self.flags = BLFeatureFlagClient(config: config, client: client) self.killSwitch = BLKillSwitchClient(config: config) - self.crashReporter = BLCrashReporter(productId: config.productId) self.keychain = BLKeychainAccessor(service: config.bundleId) - self.auditLog = BLAuditLogger(productId: config.productId) self.auth = BLAuthClient(config: config, client: client) + BLAuditLogger.configure(fileName: "\(config.productId)_audit_log.json") } // MARK: - Lifecycle @@ -84,6 +82,9 @@ public final class ByteLystPlatform { telemetry.start() flags.start(userId: userId) Task { await killSwitch.check() } + Task { @MainActor in + self.crashReporter = BLCrashReporter(productId: config.productId) + } } /// Stop all services: flush telemetry, stop flag polling.