File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 88
99import 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 " )
1318func 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 " )
2026func 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}
You can’t perform that action at this time.
0 commit comments