Warning message: init(user:realmURL is deprecated


#1

We are getting the following warning

warning message: init(user:realmURL:enableSSLValidation:isPartial:urlPrefix:)’ is deprecated: Use SyncUser.configuration()

With v 3.7.0 I see
+[RLMSyncConfiguration initWithUser] has been deprecated in favor of-[RLMSyncUser configurationWithURL:url].

Can we have some clarification on the use of SyncUser.configuration() and what the proper methods are to authenticate? I scrubbed through the examples and didn’t find a good Swift use case of the proper implementation.

Edit
It’s been 28 days with no response but I’ve found a similar question on StackOverflow


#2

@jay Our API docs are always a great resource - see the SyncUser.configuration definition here -

https://realm.io/docs/swift/3.7.6/api/Extensions/SyncUser.html#/s:So11RLMSyncUserC10RealmSwiftE13configurationAC0C0C13ConfigurationV10Foundation3URLVSg05realmH0_Sb19fullSynchronizationSb19enableSSLValidationSSSg9urlPrefixtF


#3

Yes, as the stackoverflow issue/comments say you will want to use SyncUser.current.configuration. Only the first parameter is required, meaning the others can be removed if you are going to use their defaults. :grinning:


#4

The issue is the followup question from the post on SO;

have you tried modifying an existing synced Realm to use this configuration?

either doing this

let config = SyncUser.current!.configuration(realmURL: url, fullSynchronization: false, enableSSLValidation: true, urlPrefix: nil)

or this

let config = SyncUser.current!.configuration()

Then trying to access realm does not sync. Maybe the missing piece is how to define what objects sync. It used to be like this

let realmConfig = Realm.Configuration(syncConfiguration: config, objectTypes:[MyObject.self])
let realm = try! Realm(configuration: self.realmConfig)

From the current documentation here

https://docs.realm.io/platform/using-synced-realms/opening-a-synced-realm#manually-configuring-synced-realms

It states

Realms on the Realm Object Server are using the same Realm.Configuration used to create standalone Realms, but with the syncConfiguration property on their Realm.Configuration set to a SyncConfiguration value. Synchronized realms are located by URLs.

// Create the configuration
let syncServerURL = URL(string: “realms://myinstance.cloud.realm.io/~/userRealm”)!
let config = user.configuration(realmURL: syncServerURL);

// Open the remote Realm
let realm = try! Realm(configuration: config)
// Any changes made to this Realm will be synced across all devices!

however SyncConfiguration is depreciated.

This is very circular.