How can i access public swift file in xcframwork ios?

253 views Asked by At

I have problem with xcframwork.when i create xcframwork my properties not display in my main project storyboard. When i create framework it display all properties in my storyboard.

I have created Following code

@objc 
public extension UIView  {
        // Note  : Corner radius and shadow not work both side by side so you need to outlet and set layer radius
        // other wise you can set layer.cornerradius in user defines
       
        //MARK: Border COLOR
        @IBInspectable
        var borderColor: UIColor? {
            get {
                return self.borderColor
            }
            set {
                self.layer.borderColor = newValue?.cgColor
            }
        }
    }

1 using framework

enter image description here

It display all Properties

enter image description here

now i created xcframework. all properties not display Now i am stuck with this.

anyone help me how can i create xcframwork and display all properties like normal framework. Please help me on this.

1

There are 1 answers

0
a.ajwani On

The properties in your framework are internal. When no access modifier is specified then Swift defaults to internal. enter image description here

so in your code:

var radTopLeft:CGFloat = 0 {
        didSet {
            self.setNeedsLayout()
        }
    }

is equivalent to:

internal var radTopLeft:CGFloat = 0 {
        didSet {
            self.setNeedsLayout()
        }
    }

Therefore no code outside the framework can access this property. In order to make it accessible to the framework consumer you have to mark the property public. i.e.

public var radTopLeft:CGFloat = 0 {
        didSet {
            self.setNeedsLayout()
        }
    }

Test it out: https://drive.google.com/file/d/1_WSGKRKNt4lytrVEuozn8W4WYRR6nPif/view?usp=sharing