@@ -55,7 +55,9 @@ public class IMClient {
5555
5656 let connectionDelegator : RTMConnection . Delegator
5757
58+ #if canImport(GRDB)
5859 private( set) var localStorage : IMLocalStorage ?
60+ #endif
5961
6062 /// The client delegate.
6163 public weak var delegate : IMClientDelegate ?
@@ -106,16 +108,22 @@ public class IMClient {
106108 }
107109
108110 /// Default option is `receiveUnreadMessageCountAfterSessionDidOpen`.
109- public static let `default` : Options = [
110- . receiveUnreadMessageCountAfterSessionDidOpen,
111- . usingLocalStorage
112- ]
111+ public static let `default` : Options = {
112+ #if canImport(GRDB)
113+ return [ . receiveUnreadMessageCountAfterSessionDidOpen,
114+ . usingLocalStorage]
115+ #else
116+ return [ . receiveUnreadMessageCountAfterSessionDidOpen]
117+ #endif
118+ } ( )
113119
114120 /// Receive unread message count after session did open.
115121 public static let receiveUnreadMessageCountAfterSessionDidOpen = Options ( rawValue: 1 << 0 )
116122
123+ #if canImport(GRDB)
117124 /// Use local storage.
118125 public static let usingLocalStorage = Options ( rawValue: 1 << 1 )
126+ #endif
119127
120128 var lcimProtocol : RTMConnection . LCIMProtocol {
121129 if contains ( . receiveUnreadMessageCountAfterSessionDidOpen) {
@@ -202,6 +210,7 @@ public class IMClient {
202210 self . underlyingLocalRecord = localRecord
203211 }
204212
213+ #if canImport(GRDB)
205214 if options. contains ( . usingLocalStorage) {
206215 let databaseURL = try localStorageContext. fileURL (
207216 place: . persistentData,
@@ -215,6 +224,7 @@ public class IMClient {
215224 initialize success.
216225 """ )
217226 }
227+ #endif
218228 }
219229
220230 // directly init `connection` is better, lazy init is not a good choice.
@@ -936,6 +946,7 @@ extension IMClient {
936946
937947// MARK: Local Storage
938948
949+ #if canImport(GRDB)
939950extension IMClient {
940951
941952 /// Open database of the local storage.
@@ -1059,6 +1070,7 @@ extension IMClient {
10591070 }
10601071
10611072}
1073+ #endif
10621074
10631075// MARK: Internal
10641076
@@ -1300,7 +1312,9 @@ extension IMClient {
13001312 if let invalidLocalConvCache = droppable [ " invalidLocalConvCache " ] as? Bool , invalidLocalConvCache {
13011313 for conv in convsSnapshot {
13021314 conv. isOutdated = true
1315+ #if canImport(GRDB)
13031316 conv. tryUpdateLocalStorageData ( client: self , outdated: true )
1317+ #endif
13041318 }
13051319 } else if let notifications = droppable [ " notifications " ] as? [ [ String : Any ] ] {
13061320 mapReduce ( notifications)
@@ -1848,7 +1862,9 @@ extension IMClient {
18481862 let _ = self . validInFetchingNotificationsCachedConvMapSnapshot ? [ conversationID]
18491863 {
18501864 conversation. isOutdated = true
1865+ #if canImport(GRDB)
18511866 conversation. tryUpdateLocalStorageData ( client: client, outdated: true )
1867+ #endif
18521868 }
18531869 if let event: IMConversationEvent = tuple. event {
18541870 client. eventQueue. async {
0 commit comments