Shooting in the dark here but there could be a few causes. First though, markerBody object is undefined in your question so it’s possible that could be the cause.
Also, if you’re opening Realm for the first time, you need to do it with .asyncOpen to get the server and your local realm aligned. See Open a Synced Realm
Also force unwrapping optionals is not advised
app.currentUser()?
protect your code by handling it in case it’s nil
guard let user = thisApp.currentUser() else {
print("no user object, please log in")
return
}
Also, you’re specifying three object types and the last one doesn’t appear to be used and is undefined in the question so perhaps it doesn’t have a correct _partition
Thanks a lot, Jay. I checked all of causes you pointed out, but same error still occurred.
Next, I created another xcode project and build simplified application, then BadChangeset error while writing didn’t occur.
So, I uninstalled and reinstalled Realm, RealmSwift and application itself on a Simulator, then I finally added object successfully from main application.
@Shi_Miya This is likely due to the local realm state which is stored on the simulator. If at some previous time you had opened the realm with a different partitionKey value then you would likely get this error. Clearing the simulator by uninstalling the app or wiping the simulator is the best way to clear this.