According to the documentation,
close is not available in Swift SDK.
There is no need to manually close a realm in Swift or Objective-C. When a realm goes out of scope and is removed from memory due to ARC , the realm is closed.
However when handling a user logout use case, after the user logged out and try to log in again the Realm through a “Realm at path XXX already opened with different sync user.”
user.logOut would not close the Realm for me and I do not think I have any previous Realm ref stored in the memory.
I have even tried to delete the Realm database file associated with the sync user but once the user got re-logged into the app. The same error appears.