Realm iOS Tutorial, 'Build iOS app from scratch'


#1

I’ve followed the ‘Build iOS app from scratch’ tutorial on the realm website step by step and watched the video. Everything appears to be in order. Unfortunately the tutorial does not include the full source code for reference.

When I run the project it connects to the ROS and creates the realm without a problem. I can see this in the realm browser and through a web browser.

However, I get the following in the Xcode console and the app does not work.

realmTask[1000:40858] Sync: Connection[1]: Connected to endpoint ‘127.0.0.1:9080’
realmTask[1000:40858] Sync: Connection[1]: Writing failed: End of input
realmTask[1000:40858] Sync: Connection[1]: Connection closed due to error

The app does not crash, the error repeats over and over, and the app won’t do anything.

Here is my setup code.

func setupRealm() {
// Log in existing user with username and password
let username = "abcdefg"  
let password = "1234"  

SyncUser.logIn(with: .usernamePassword(username: username, password: password, register: false), server: URL(string: "http://127.0.0.1:9080")!) { user, error in
    guard let user = user else {
        fatalError(String(describing: error))
    }

    DispatchQueue.main.async {
        // Open Realm
        let configuration = Realm.Configuration(
            syncConfiguration: SyncConfiguration(user: user, realmURL: URL(string: "realm://127.0.0.1:9080/~/realmtasks")!)
        )
        self.realm = try! Realm(configuration: configuration)

        // Show initial tasks
        func updateList() {
            if self.items.realm == nil, let list = self.realm.objects(TaskList.self).first {
                self.items = list.items
            }
            self.tableView.reloadData()
        }
        updateList()

        // Notify us when Realm changes
        self.notificationToken = self.realm.observe { _,_ in
            updateList()
        }
    }
}
}

deinit {
       notificationToken?.invalidate()
}

#2

Just wondering why no one replied :frowning:


#3

ROS no longer supported.


#4

Well, ROS is still referred to in the (laggy) documentation Realm Platform but its currently Realm Cloud for readers future reference if you are looking for a online real-time database.