Create synched realm-sync schemas server side using development mode

I am in a similar position to @Alex_Tang1 a year ago (responded to by @Chris_Bush) in that I have an existing iOS (swift) app using a local realm and plan to make this multi-user through using Mongo DB Realm-sync. I too have completed Task Tracker successfully and have created a synched realm for my app with developer mode active so that the server side schemas can be created for me automatically through their definition in my mobile app as intended.

I am now following the Quick start with Sync document:

I have successfully registered users on the server side via SIWA (Sign in with Apple) on a real device, as well as email/password users and anon users (since SIWA is not an available option on the XCode iPhone simulators).

I have also successfully opened a synced Realm (asynchronously of course as suggested!) based on a partition strategy using an _partition field which I have defined in each of my objects locally.
My expectation was that I would be able to write new objects in my local app to the synched realm and that they would appear on the server side database as schemas and collections im my flashCardGenie database. I therefore started with one object (the Account object) and wrote an instance of that class to the realm. However as soon as I do that the server logs a permissions error (see below)


And the error advises:

ending session with error: user cannot perform additive schema changes without write access: non-breaking schema change: adding schema for Realm table “Account”, schema changes from clients are restricted when developer mode is disabled (ProtocolErrorCode=206)

So sync seems to be in place but given that developer mode is definitely on (as advised at the top of the logs screen above) what is the rationale for the schema changes being prevented in this case. Presumably I have not done something I should have done but I am struggling to discover what!

Update to this question:

After some more analysis, I have discovered a little more about the point at which the permissions error occurs. It is after the Realm.asynchOpen command returns with a success result to open the session, but that the error is not then reliant on any other local iOS processes.

I am guessing that because Development mode is on, once the session opens successfully it is at this point that the server side attempts to create the schemas based on the local iOS definitions and the Account schema happens to be the first one it attempts. It then fails with the permissions error, closes the session and the connection immediately after that.

The question therefore remains why Development mode has been disabled despite it being on?

Hi Chris,

According to the error this appears to be a Sync permissions issue on the partition being opened.
user cannot perform additive schema changes without write access

Your write access for sync is currently this:

{
  "%%partition": "%%user.id"
}

Please try changing the permission to True to troubleshoot if the change will be allowed.

Regards
Manny

1 Like

Hi @Mansoor_Omar ,

Yes ! That has fixed it. Hurrah!
Is this an undocumented pre-requisite for development mode to work, or did I miss this in the docs somewhere? If the latter, please can you give me the link so that I can review. Many thanks for your help.,

Chris

1 Like

Hi Chris,

I didn’t find it explicitly mentioned but it would be implied since enabling development mode means a client needs to write to the cloud schema. Generally this would be used in the initial development stage of the app where permissions can be defaulted to true until the schema is in order. Please know that you should not enable development mode in a production environment when needing to apply breaking schema changes - you can use the “partner collection” strategy for doing so.

Regards

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.