From b068e4bc1aa4ce05dd89e9eeee24744e86f5a2c6 Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Sat, 28 Feb 2026 22:51:26 -0800 Subject: [PATCH] fix(swift-sdk): guard BLBiometricAuth and BLCrashReporter for watchOS compatibility BLBiometricAuth imports LocalAuthentication (unavailable on watchOS). BLCrashReporter imports MetricKit (unavailable on watchOS). Package.swift declares watchOS 10+ as a platform target. Fix: wrap both files in #if canImport() guards. BLCrashReport model struct stays outside the guard (data-only, all platforms). --- .../swift-platform-sdk/Sources/BLBiometricAuth.swift | 7 ++++++- .../swift-platform-sdk/Sources/BLCrashReporter.swift | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/swift-platform-sdk/Sources/BLBiometricAuth.swift b/packages/swift-platform-sdk/Sources/BLBiometricAuth.swift index 0c55faed..9435ec69 100644 --- a/packages/swift-platform-sdk/Sources/BLBiometricAuth.swift +++ b/packages/swift-platform-sdk/Sources/BLBiometricAuth.swift @@ -1,11 +1,15 @@ // ── Biometric Authentication ──────────────────────────────── // Generic Face ID / Touch ID wrapper using LocalAuthentication. // Product apps pass a custom reason string for the biometric prompt. +// Not available on watchOS — guarded with #if canImport. import Foundation + +#if canImport(LocalAuthentication) import LocalAuthentication -/// Generic biometric authentication for all ByteLyst iOS apps. +/// Generic biometric authentication for all ByteLyst iOS/macOS apps. +/// Not available on watchOS (LocalAuthentication is iOS/macOS only). public enum BLBiometricAuth { public enum BiometricType { @@ -70,3 +74,4 @@ public enum BLBiometricAuth { } } } +#endif diff --git a/packages/swift-platform-sdk/Sources/BLCrashReporter.swift b/packages/swift-platform-sdk/Sources/BLCrashReporter.swift index d1d24428..4151fb06 100644 --- a/packages/swift-platform-sdk/Sources/BLCrashReporter.swift +++ b/packages/swift-platform-sdk/Sources/BLCrashReporter.swift @@ -2,11 +2,12 @@ // Generic MetricKit-based crash and performance reporting. // Stores crash diagnostics locally for debugging and feedback forms. // Product apps configure with a product-specific persistence key. +// Not available on watchOS — MetricKit is iOS/macOS only. import Foundation -import MetricKit /// Crash report model stored locally. +/// Available on all platforms (data-only struct). public struct BLCrashReport: Codable, Identifiable, Sendable { public let id: String public let date: Date @@ -25,8 +26,12 @@ public struct BLCrashReport: Codable, Identifiable, Sendable { } } -/// Generic MetricKit crash reporter for all ByteLyst iOS apps. +#if canImport(MetricKit) +import MetricKit + +/// Generic MetricKit crash reporter for all ByteLyst iOS/macOS apps. /// Subscribes to MetricKit, stores crash reports in UserDefaults. +/// Not available on watchOS (MetricKit is iOS 13+ / macOS 12+ only). @MainActor public final class BLCrashReporter: NSObject, ObservableObject, MXMetricManagerSubscriber { @@ -127,3 +132,4 @@ public final class BLCrashReporter: NSObject, ObservableObject, MXMetricManagerS diagnosticCount = loadCrashReports().count } } +#endif