Skip to content

Commit 450015a

Browse files
committed
Make address cache work in UI process
1 parent 3ff0ef4 commit 450015a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ios/MullvadRustRuntime/MullvadAddressCacheKeychainStore.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@
88

99
import MullvadSettings
1010

11+
/// Whether the settings store is available. It requires `ApplicationSecurityGroupIdentifier`
12+
/// to be present in the main bundle's Info.plist, which is not the case in e.g. UI test runners.
13+
private let isSettingsStoreAvailable: Bool = Bundle.main
14+
.object(forInfoDictionaryKey: "ApplicationSecurityGroupIdentifier") != nil
15+
1116
/// Store the address cache, given to us by the Rust code, to the keychain
1217
@_cdecl("swift_store_address_cache")
1318
func storeAddressCache(_ pointer: UnsafeRawPointer, dataSize: UInt64) {
19+
guard isSettingsStoreAvailable else { return }
1420
let data = Data(bytes: pointer, count: Int(dataSize))
1521
// if writing to the Keychain fails, it will do so silently.
1622
try? SettingsManager.writeAddressCache(data)
1723
}
1824

1925
@_cdecl("swift_read_address_cache")
2026
func readAddressCache() -> SwiftData {
27+
guard isSettingsStoreAvailable else { return SwiftData(data: NSData()) }
2128
let data = (try? SettingsManager.readAddressCache()) ?? Data()
2229
return SwiftData(data: data as NSData)
2330
}

0 commit comments

Comments
 (0)