From 4d2bdaf2194a88556761c38a1baadf1b2579775c Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Thu, 18 Jul 2024 11:53:00 +0200 Subject: [PATCH] Safely unwrap API Version in case MARKETING_VERSION is missing (IOS-262) --- MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift index a2a6c6346..70ea4ce5f 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift @@ -32,7 +32,7 @@ public final class APIService { public init(backgroundManagedObjectContext: NSManagedObjectContext) { self.backgroundManagedObjectContext = backgroundManagedObjectContext - let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String + let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "Unknown" let configuration = URLSessionConfiguration.default configuration.httpAdditionalHeaders = ["User-Agent" : "mastodon-ios/" + appVersion] self.session = URLSession(configuration: configuration)