2

I have a Controller where I need to import two pods.

import Realm
import ReactiveSwift

Problem is that both have a type named Property.

Now if I use that with importing both pods then it gives me compile time error Cannot specialize a non-generic definition.

For workaround,

I created a separate file and added extension to controller with importing Realm in that only. And kept ReactiveSwift in controller file. This helps me to prevent the error. But is this the best way?

Parth Adroja
  • 13,198
  • 5
  • 37
  • 71

2 Answers2

3

In order for the compiler to be able to decide which Property element you want to use, you have to add the namespace. In this case:

  • Realm.Property to use the Property element from Realm
  • ReactiveSwift.Property to use the Property element from ReactiveSwift
Daniel
  • 20,420
  • 10
  • 92
  • 149
0

So here problem is 'Property' is available in RealmSwift as well and ReactiveSwift as well.

So here if you want to use Realm property as above answer suggest that you can add Realm.property or ReactiveSwift.Property to access element.

Apart from it you can make typealias as well and also you can divide your code into two files using extension

Anil Kukadeja
  • 1,348
  • 1
  • 14
  • 27