Unsupported Instruction Error on Swift - asyncOpen


I’m attempting to take an existing Realm Local app and migrate it to using Realm Sync. I’ve been bringing the remote and local schema into parity, and after eliminating all cases where the Realm Sync complained about a schema mismatch, I’ve changed our open code to using asyncOpen. After having done so, I now get the following error in the asyncOpen error parameter:

code: 1, domain: io.realm, “Unsupported instruction”

Without further context, I really don’t have any way of understanding what is breaking here. Has anyone else ran into this?


If you can provide some code and example data, we could try to reproduce in house to narrow down the cause


Here’s a cut down version of how I’m opening the database:

      let syncCredentials = SyncCredentials(customToken: "\(username):\(password)", provider: Provider.usernamePassword, userInfo: ["register": false, "other_info": some_string])
        let syncAuthUrl = URL(string: "http://localhost:9080/")!
        SyncUser.logIn(with: syncCredentials, server: syncAuthUrl) { (user: SyncUser?, error: Error?) in
            if error != nil {
                DispatchQueue.main.async { fail(error!) }
            } else {
                if let syncUser = user {
                    let syncServerURL = URL(string: "realm://localhost:9080/my-collection")!
                    var realmConfig = Realm.Configuration()
                    realmConfig.syncConfiguration = SyncConfiguration(user: syncUser, realmURL: syncServerURL)
                    realmConfig.deleteRealmIfMigrationNeeded = true
                    Realm.Configuration.defaultConfiguration = realmConfig
                    Realm.asyncOpen(configuration: realmConfig, callbackQueue: DispatchQueue.main) { (_realm:Realm?, error: Error?) in
                        if error != nil {
                            // As per the forum post, I repeatedly arrive at this failure point where error is not nil and is an unsupported instruction error
                            DispatchQueue.main.async { fail(error!) }
                        } else {
                            DispatchQue.main.async { succeed() }
                } else {
                    DispatchQueue.main.async { fail(NSError(domain: "No user present on Realm auth", code: 1, userInfo: Optional.none)) }



After some investigation, this appears to be a related to an issue with my schema where the server is declaring a field exists of type string[], whereas the client does not have any such awareness of this. For some reason, when the schema is being initially applied, RemoveProperty schema change is being applied to it in Realm’s initial schema creation. This is falling afoul of some logic error I believe ( I haven’t been able to successfully breakpoint in Realm core to figure out why ).

Needless to say, “Unsupported Instruction” is not a very helpful error. There should be a better explanation of why things are failing here. I feel like I’m falling afoul of some weird edge case implied by the comment in object_store.cpp:556:

        // Note that in normal operation none of these will be hit, as if we're
        // creating the initial tables there shouldn't be anything to update.
        // Implementing these makes us better able to handle weird
        // not-quite-correct files produced by other things and has no obvious
        // downside.

as my initial schema creation is repeatedly hitting AddProperty and AddIndex calls, perhaps implying a schema disagreement or drift between the client and server. If that’s the case though I would have expected some sort of indicator or error message rather than “Unsupported Instruction”.


Confirmed, what I think happening here is:

  1. I have a Realm Object Server with a schema defined of S1
  2. I have a client with a schema informed via the models of S2
  3. Upon initial connect, the client creates tables with matching properties of S1
  4. For all columns in S2 that are not in S1, an AddProperty change is applied ( this makes sense, and seems to work )
  5. For all columns in S1 that are not in S2, a RemoveProperty change is applied. This causes the Unsupported Instruction to be thrown upwards, due to some throw that I’m not able to breakpoint correctly.

This is with RealmSwift 3.1.1 and realm-object-server 2.7.1, from a clean application start ( prior database files are deleted ).