I have two Packages: FirstModule
and AnotherModule
, and each of them defines
extension CGPoint {
public static func + (lhs: CGPoint, rhs: CGPoint) -> CGPoint {
CGPoint(x: lhs.x + rhs.x, y: lhs.y+rhs.y)
}
}
Also in main app I defined
extension CGPoint {
#if !canImport(FirstModule) && !canImport(AnotherModule)
public static func + (lhs: CGPoint, rhs: CGPoint) -> CGPoint {
CGPoint(x: lhs.x + rhs.x, y: lhs.y + rhs.y)
}
...
#endif
}
and some class in another file:
#import FirstModule
#import AnotherModule
class Whatever() {
///Uses CGPoint + CGPoint
}
Unfortunately, compiler throws an error: Ambiguous use of operator '+'
and point on both imported modules.
Not all classes in my app use FirstModule
and AnotherModule
but they need just func + ()
How to avoid import func + ()
from FirstModule
and AnotherModule
in Whatever
class?