From f1dd3fe97b081c55046b6eb76dda1fbaac869ad8 Mon Sep 17 00:00:00 2001 From: Jonas Rottmann Date: Fri, 24 Nov 2023 20:26:56 +0100 Subject: [PATCH] Fix validating Bundle for whenInUse permission --- Sources/SwiftLocation/Support/Extensions.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftLocation/Support/Extensions.swift b/Sources/SwiftLocation/Support/Extensions.swift index 4e6fe17..692c23d 100644 --- a/Sources/SwiftLocation/Support/Extensions.swift +++ b/Sources/SwiftLocation/Support/Extensions.swift @@ -41,7 +41,7 @@ extension CLLocationManager: LocationManagerProtocol { switch permission { #if !os(tvOS) case .always: - if !Bundle.hasAlwaysPermission() { + if !Bundle.hasAlwaysAndWhenInUsePermission() { throw LocationErrors.plistNotConfigured } #endif @@ -103,8 +103,8 @@ extension CLAuthorizationStatus: CustomStringConvertible { extension Bundle { - private static let always = "NSLocationAlwaysUsageDescription" - private static let whenInUse = "NSLocationAlwaysAndWhenInUseUsageDescription" + private static let alwaysAndWhenInUse = "NSLocationAlwaysAndWhenInUseUsageDescription" + private static let whenInUse = "NSLocationWhenInUseUsageDescription" private static let temporary = "NSLocationTemporaryUsageDescriptionDictionary" static func hasTemporaryPermission(purposeKey: String) -> Bool { @@ -120,9 +120,8 @@ extension Bundle { !(Bundle.main.object(forInfoDictionaryKey: whenInUse) as? String ?? "").isEmpty } - static func hasAlwaysPermission() -> Bool { - !(Bundle.main.object(forInfoDictionaryKey: always) as? String ?? "").isEmpty && - !( Bundle.main.object(forInfoDictionaryKey: whenInUse) as? String ?? "").isEmpty + static func hasAlwaysAndWhenInUsePermission() -> Bool { + !(Bundle.main.object(forInfoDictionaryKey: alwaysAndWhenInUse) as? String ?? "").isEmpty } }