RxSwiftCommunity / RxRealm

RxSwift extension for RealmSwift's types
MIT License
1.15k stars 263 forks source link

Does not conform to protocol 'NotificationEmitter' using Swift Packet Manager #179

Closed AllenTheobald closed 2 years ago

AllenTheobald commented 2 years ago

Hello,

Test project: Xcode 12.5.1, Swift 5, iOS deploy 11.0

I create a new empty iOS project, add RxRealm 5.0.3 (exact version) via Swift Packet Manager. SPM brings in the following package dependencies:

Realm 10.21.1 RealmDatabase 11.8.0 RxSwift 6.5.0

When I compile, I get the following errors:

RxRealm.swift:42:1: error: type 'List' does not conform to protocol 'NotificationEmitter' RxRealm.swift:53:1: error: type 'AnyRealmCollection' does not conform to protocol 'NotificationEmitter' RxRealm.swift:64:1: error: type 'Results' does not conform to protocol 'NotificationEmitter' RxRealm.swift:64:1: error: type 'Results' does not conform to protocol 'NotificationEmitter'

I would love to contribute a fix for this, if someone could point me in the right direction.

arshiacont commented 2 years ago

Update to RxRealm 5.0.4 and close ticket if applicable.

AllenTheobald commented 2 years ago

I couldn't get RxRealm 5.0.4 to work at all. However, if I install these packages in this order, using exact version, then RxRealm 5.0.3 will compile and run:

Realm-swift 10.20.1 Realm-cocoa 10.20.1 RxRealm 5.0.3

lihao6485 commented 2 years ago

Hi @AllenTheobald do you mind share the error? I'm not using RxRealm in SPM but I test to add it with SPM in a test project it is working fine.

AllenTheobald commented 2 years ago

Thanks! I have written the steps below. If you still cannot reproduce, I can share the test app repo.

Step 1: Describe your environment Xcode version: 12.5.1 Swift version: 5 iOS deployment target: 11.0 RxRealm (exact) version: 5.0.3 Installation method: SPM

Step 2: Steps to recreate

  1. Create a new empty iOS project
  2. Add repository, https://github.com/RxSwiftCommunity/RxRealm, 5.0.3 (exact version)
    • Note: Realm 10.21.1, RealmDatabase 11.8.0, RxSwift 6.5.0 are added dependencies
  3. Cmd-B
    • Note: When I compile, I get the following errors:

RxRealm.swift:42:1: error: type 'List' does not conform to protocol 'NotificationEmitter' RxRealm.swift:53:1: error: type 'AnyRealmCollection' does not conform to protocol 'NotificationEmitter' RxRealm.swift:64:1: error: type 'Results' does not conform to protocol 'NotificationEmitter' RxRealm.swift:64:1: error: type 'Results' does not conform to protocol 'NotificationEmitter'

  1. Remove RxRealm package from SPM
  2. Add realm-cocoa package first 10.20.1 (exact version)
    • Note: this is a lower version than what was brought in above as a dependency.
  3. Re-add RxRealm 5.0.3 (exact version)
  4. Cmd-B builds successfully
arshiacont commented 2 years ago

@AllenTheobald v5.0.3 won't compile with Realm 10.21.x (but with prior versions). Have you tried updating to 5.0.4?

AllenTheobald commented 2 years ago

v5.0.4 compiles/runs with Realm 10.21.x on my iPhone, but does not compile/run on my iPad. The iPad is running iOS 12.2. I find this weird, but remember there was some wonkiness with iOS 12.2. Interestingly, the .ipa I create can be installed/run on the iOS12.2 device - just not installing through the debugger.

arshiacont commented 2 years ago

In case it helps: It seems like Realm traverses all existing classes in your App and in Runtime. So even if you think that an iOS 13+ class is not being used in your iOS 12 device, it will be at some point by Realm unless you choose the right @availability vs #available . You need to make sure you exclude those classes in Runtime... learned this the hard way myself! :)