2 modules conflict because of "overriding" the same variable in Swift

40 Views Asked by At

The first library: https://github.com/SimeonRumy/constraints/blob/main/Sources/Constraints/View%2BLayoutBlocks.swift

public extension View {
...
var width: LayoutBlock<Dimension> { LayoutBlock(anchor: self.widthAnchor) }
...
}

The second library: https://github.com/AssistoLab/DropDown/blob/master/DropDown/src/DropDown.swift

public final class DropDown: UIView {
...
public var width: CGFloat? {
        didSet { setNeedsUpdateConstraints() }
    }
...

The second library is always imported with SPM. The first one works normally when I import it with cocoapods but when I import its sources directly (I need to add significant changes to it):

Overriding non-open property outside of its defining module
Property 'width' with type 'CGFloat?' cannot override a property with type 'LayoutBlock<Dimension>' (aka 'LayoutBlock<NSLayoutDimension>')

It seems the problem is the second library contains public extension. I don't import the second library inside the sources of the first one but anyways this extension is available everywhere even with no import.

How to resolve this conficting sources correctly? Is it possible to avoid renaming "width" into something else?

0

There are 0 best solutions below