Reputation: 524
it's first time for me to develop my own pod and i create a pod with an example to implement the pod, the pod is working great but i wanted that user to be able to init with coding or using Storyboard so i tried to use @IBDesignable and @IBInspectable to be able to change the properties in view the issue i found that error saying that
file:///Users/belalmedhat/Desktop/SwipeySearch/Example/SwipeySearch/Base.lproj/Main.storyboard: error: IB Designables: Failed to render and update auto layout status for ViewController (vXZ-lx-hvc): dlopen(SwipeySearch.framework, 0x0001): tried: '/Applications/Xcode Rosetta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays/SwipeySearch.framework/SwipeySearch' (no such file), '/Applications/Xcode Rosetta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/SwipeySearch.framework/SwipeySearch' (no such file), '/Applications/Xcode Rosetta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRootSwipeySearch.framework' (no such file), 'SwipeySearch.framework' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Library/Frameworks/SwipeySearch.framework/SwipeySearch' (no such file)
and here is the code for the search view
@IBDesignable public class SwipeySearchClass: UIView {
@IBOutlet var contentView: UIView!
@IBOutlet weak public var searchView: UIView!
@IBOutlet weak public var searchButton: UIButton!
@IBInspectable public var cornerRadius: CGFloat = 0 {
didSet {
contentView.layer.cornerRadius = cornerRadius
contentView.layer.masksToBounds = cornerRadius > 0
}
}
@IBInspectable public var borderWidth: CGFloat = 0 {
didSet {
contentView.layer.borderWidth = borderWidth
}
}
@IBInspectable public var borderColor: UIColor? {
didSet {
contentView.layer.borderColor = borderColor?.cgColor
}
}
/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
}
*/
public override init(frame: CGRect) {
super.init(frame: frame)
initMe()
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initMe()
}
public override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
initMe()
}
public override func awakeFromNib() {
super.awakeFromNib()
initMe()
}
private func initMe(){
let bundle = Bundle(for: SwipeySearchClass.self)
let view = UINib(nibName: "SwipeySearchView", bundle: bundle).instantiate(withOwner: self, options: nil).first as! UIView
view.frame = self.bounds
view.autoresizingMask = [.flexibleWidth,.flexibleHeight]
addSubview(view)
}
public func buttonShape(type:SearchShape) {
searchButton.clipsToBounds = true
switch type {
case .circle:
searchButton.layer.cornerRadius = searchButton.frame.width/2
break
case .roundedSquare(let corner):
searchButton.layer.cornerRadius = corner
break
}
}
}
public enum SearchShape {
case circle
case roundedSquare(corner:CGFloat)
}
Upvotes: 1
Views: 99