diff --git a/Common/Extensions/NSBundle.swift b/Common/Extensions/NSBundle.swift index 57b7d6ad88..0e6dd493b7 100644 --- a/Common/Extensions/NSBundle.swift +++ b/Common/Extensions/NSBundle.swift @@ -60,5 +60,27 @@ extension Bundle { } return .days(localCacheDurationDays) } + + var hostIdentifier: String { + var identifier = bundleIdentifier ?? "com.loopkit.Loop" + let components = identifier.components(separatedBy: ".") + // DIY Loop has bundle identifiers like com.UY653SP37Q.loopkit.Loop + if components[2] == "loopkit" && components[3] == "Loop" { + identifier = "com.loopkit.Loop" + } + return identifier + } + + var hostVersion: String { + var semanticVersion = shortVersionString + + while semanticVersion.split(separator: ".").count < 3 { + semanticVersion += ".0" + } + + semanticVersion += "+\(Bundle.main.version)" + + return semanticVersion + } } diff --git a/Loop/Managers/OnboardingManager.swift b/Loop/Managers/OnboardingManager.swift index 781d4272d4..6435e126ed 100644 --- a/Loop/Managers/OnboardingManager.swift +++ b/Loop/Managers/OnboardingManager.swift @@ -429,22 +429,6 @@ extension OnboardingManager: ServiceProvider { var activeServices: [Service] { servicesManager.activeServices } var availableServices: [ServiceDescriptor] { servicesManager.availableServices } - - func onboardService(withIdentifier identifier: String) -> Swift.Result, Error> { - guard let service = activeServices.first(where: { $0.pluginIdentifier == identifier }) else { - return servicesManager.setupService(withIdentifier: identifier) - } - - if service.isOnboarded { - return .success(.createdAndOnboarded(service)) - } - - guard let serviceUI = service as? ServiceUI else { - return .failure(OnboardingError.invalidState) - } - - return .success(.userInteractionRequired(serviceUI.settingsViewController(colorPalette: .default))) - } } // MARK: - TherapySettingsProvider @@ -455,10 +439,22 @@ extension OnboardingManager: TherapySettingsProvider { } } +// MARK: - PluginHost + +extension OnboardingManager: PluginHost { + nonisolated var hostIdentifier: String { + return Bundle.main.hostIdentifier + } + + nonisolated var hostVersion: String { + return Bundle.main.hostVersion + } +} + // MARK: - OnboardingProvider extension OnboardingManager: OnboardingProvider { - var allowDebugFeatures: Bool { FeatureFlags.allowDebugFeatures } // NOTE: DEBUG FEATURES - DEBUG AND TEST ONLY + nonisolated var allowDebugFeatures: Bool { FeatureFlags.allowDebugFeatures } // NOTE: DEBUG FEATURES - DEBUG AND TEST ONLY } // MARK: - SupportProvider diff --git a/Loop/Managers/ServicesManager.swift b/Loop/Managers/ServicesManager.swift index 26c27f44a1..3751c2651a 100644 --- a/Loop/Managers/ServicesManager.swift +++ b/Loop/Managers/ServicesManager.swift @@ -259,31 +259,20 @@ extension ServicesManager: StatefulPluggableDelegate { } } -// MARK: - ServiceDelegate - -extension ServicesManager: ServiceDelegate { - var hostIdentifier: String { - var identifier = Bundle.main.bundleIdentifier ?? "com.loopkit.Loop" - let components = identifier.components(separatedBy: ".") - // DIY Loop has bundle identifiers like com.UY653SP37Q.loopkit.Loop - if components[2] == "loopkit" && components[3] == "Loop" { - identifier = "com.loopkit.Looo" - } - return identifier +// MARK: - PluginHost +extension ServicesManager: PluginHost { + nonisolated var hostIdentifier: String { + return Bundle.main.hostIdentifier } - var hostVersion: String { - var semanticVersion = Bundle.main.shortVersionString - - while semanticVersion.split(separator: ".").count < 3 { - semanticVersion += ".0" - } + nonisolated var hostVersion: String { + return Bundle.main.hostVersion + } +} - semanticVersion += "+\(Bundle.main.version)" +// MARK: - ServiceDelegate - return semanticVersion - } - +extension ServicesManager: ServiceDelegate { func enactRemoteOverride(name: String, durationTime: TimeInterval?, remoteAddress: String) async throws { var duration: TemporaryScheduleOverride.Duration? = nil