Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

460
Views
Build compile errors in RxRealm.swift after RxRealm pod update: Type 'List<Element>' does not conform to protocol 'NotificationEmitter'

Here's the top portion of the file RxRealm.swift. (nowhere else in the file are there compile errors nor the "observe" func.

//
//  RxRealm extensions
//
//  Copyright (c) 2016 RxSwiftCommunity. All rights reserved.
//  Check the LICENSE file for details
//  Created by Marin Todorov
//

import Foundation
import RealmSwift
import RxSwift

public enum RxRealmError: Error {
  case objectDeleted
  case unknown
}

// MARK: Realm Collections type extensions

/**
 `NotificationEmitter` is a protocol to allow for Realm's collections to be handled in a generic way.

 All collections already include a `addNotificationBlock(_:)` method - making them conform to `NotificationEmitter` just makes it easier to add Rx methods to them.

 The methods of essence in this protocol are `asObservable(...)`, which allow for observing for changes on Realm's collections.
 */
public protocol NotificationEmitter {
  associatedtype ElementType: RealmCollectionValue

  /**
   Returns a `NotificationToken`, which while retained enables change notifications for the current collection.

   - returns: `NotificationToken` - retain this value to keep notifications being emitted for the current collection.
   */
  func observe(on queue: DispatchQueue?, _ block: @escaping (RealmCollectionChange<Self>) -> Void) -> NotificationToken

  func toArray() -> [ElementType]

  func toAnyCollection() -> AnyRealmCollection<ElementType>
}

extension List: NotificationEmitter {
  public func toAnyCollection() -> AnyRealmCollection<Element> {
    return AnyRealmCollection<Element>(self)
  }

  public typealias ElementType = Element
  public func toArray() -> [Element] {
    return Array(self)
  }
}

extension AnyRealmCollection: NotificationEmitter {
  public func toAnyCollection() -> AnyRealmCollection<Element> {
    return AnyRealmCollection<ElementType>(self)
  }

  public typealias ElementType = Element
  public func toArray() -> [Element] {
    return Array(self)
  }
}

extension Results: NotificationEmitter {
  public func toAnyCollection() -> AnyRealmCollection<Element> {
    return AnyRealmCollection<ElementType>(self)
  }

  public typealias ElementType = Element
  public func toArray() -> [Element] {
    return Array(self)
  }
}

extension LinkingObjects: NotificationEmitter {
  public func toAnyCollection() -> AnyRealmCollection<Element> {
    return AnyRealmCollection<ElementType>(self)
  }

  public typealias ElementType = Element
  public func toArray() -> [Element] {
    return Array(self)
  }
}

I've tried adding the protocol stubs as suggested but I don't know what goes inside the added observe function.

public func observe(on queue: DispatchQueue?, _ block: @escaping (RealmCollectionChange<List<Element>>) -> Void) -> NotificationToken {
        // what goes here? 
    }

I've tried leaving the function blank but it spits out another error: "Missing return in a function expected to return 'NotificationToken' (aka 'RLMNotificationToken')"

If I put in a return function I have no idea what to put in there. Obv it's the NotificiationToken type, but now I'm lost.

This is really above my head, but there's nothing about it on Cocoapods https://cocoapods.org/pods/RxRealm

Any ideas how to fix this?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

working for me:

pod 'Realm', '10.20.1'  
pod 'RealmSwift', '10.20.1'  
pod 'RxRealm', '4.0.3'
over 4 years ago · Santiago Trujillo Report

0

In Xcode 13.2.1, you can add this method, from xcode suggestion extension of List, Results...

public func observe(on queue: DispatchQueue?, _ block: @escaping (RealmCollectionChange<List<Element>>) -> Void) -> NotificationToken {
        // what goes here? 
    }

--->

public func observe(on queue: DispatchQueue?, _ block: @escaping (RealmCollectionChange<Results<Element>>) -> Void) -> NotificationToken {
        return self.observe(keyPaths: nil, on: queue, block)
    }

Your problem will be resolve, but if you using Cocoapods, you must directly edit RXRealm file in your pods.

over 4 years ago · Santiago Trujillo Report

0

working config.

  pod 'RxSwift', '~> 5'
  pod 'RxCocoa', '~> 5'
  pod 'RxAlamofire', '~> 5.1.0'
  pod 'RxRealm'
  pod 'RealmSwift', '10.20.1'
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!