From 445afd44dbb23cee82044c7f31a5461998b5094b Mon Sep 17 00:00:00 2001 From: Lloouujjiinn Date: Sat, 16 May 2026 08:26:02 +0300 Subject: [PATCH 1/2] Avoid crashing when bundle identifier is unavailable --- SimpleKeychain/SimpleKeychain.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimpleKeychain/SimpleKeychain.swift b/SimpleKeychain/SimpleKeychain.swift index 24191d5..50ba359 100644 --- a/SimpleKeychain/SimpleKeychain.swift +++ b/SimpleKeychain/SimpleKeychain.swift @@ -35,7 +35,7 @@ public struct SimpleKeychain: @unchecked Sendable { /// - Parameter synchronizable: Whether the items should be synchronized through iCloud. Defaults to `false`. /// - Parameter attributes: Additional attributes to include in every query. Defaults to an empty dictionary. /// - Returns: A ``SimpleKeychain`` instance. - public init(service: String = Bundle.main.bundleIdentifier!, + public init(service: String = Bundle.main.bundleIdentifier ?? "SimpleKeychain", accessGroup: String? = nil, accessibility: Accessibility = .afterFirstUnlock, accessControlFlags: SecAccessControlCreateFlags? = nil, @@ -61,7 +61,7 @@ public struct SimpleKeychain: @unchecked Sendable { /// - Parameter synchronizable: Whether the items should be synchronized through iCloud. Defaults to `false`. /// - Parameter attributes: Additional attributes to include in every query. Defaults to an empty dictionary. /// - Returns: A ``SimpleKeychain`` instance. - public init(service: String = Bundle.main.bundleIdentifier!, + public init(service: String = Bundle.main.bundleIdentifier ?? "SimpleKeychain", accessGroup: String? = nil, accessibility: Accessibility = .afterFirstUnlock, accessControlFlags: SecAccessControlCreateFlags? = nil, From 1e95cdce6c85228f58b72dfc74d35c797669eeb4 Mon Sep 17 00:00:00 2001 From: Lloouujjiinn Date: Sat, 16 May 2026 08:26:04 +0300 Subject: [PATCH 2/2] Cover default service fallback --- SimpleKeychainTests/SimpleKeychainSpec.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SimpleKeychainTests/SimpleKeychainSpec.swift b/SimpleKeychainTests/SimpleKeychainSpec.swift index c167430..9bca9a8 100644 --- a/SimpleKeychainTests/SimpleKeychainSpec.swift +++ b/SimpleKeychainTests/SimpleKeychainSpec.swift @@ -23,7 +23,7 @@ class SimpleKeychainTests: XCTestCase { func testInitializationWithDefaultValues() { XCTAssertEqual(sut.accessGroup, nil) - XCTAssertEqual(sut.service, Bundle.main.bundleIdentifier) + XCTAssertEqual(sut.service, Bundle.main.bundleIdentifier ?? "SimpleKeychain") XCTAssertEqual(sut.accessibility, Accessibility.afterFirstUnlock) XCTAssertEqual(sut.accessControlFlags, nil) XCTAssertEqual(sut.isSynchronizable, false) @@ -374,4 +374,3 @@ public extension Dictionary where Key == String, Value == Any { public func ==(lhs: [String: Any], rhs: [String: Any]) -> Bool { return NSDictionary(dictionary: lhs).isEqual(to: rhs) } -