Xcode - IB可设计:无法渲染和更新自动布局(找不到合适的图像)

时间:2018-06-16 11:10:52

标签: ios swift xcode xib ibdesignable

我正在尝试从.xib文件中实现自定义UIView,我希望能够在我的一个故事板中进行检查。但是,我收到了构建时错误:

  

IB Designables:无法呈现和更新LoginViewController(BYZ-38-t0r)的自动布局状态:dlopen(App.app,1):找不到合适的图像。找到了:       App.app:无法将不可刷新的段__TEXT映射到0x100000000,大小为0x268000

我正在使用CocoaPods并读到这是由于版本1.5中的错误。我尝试了一些解决方法并将其降级到1.4而没有任何结果。我还尝试删除DerivedData文件夹并清理/重建项目。

我的.xib文件包含一个简单的临时UIView,这是相应的代码:

import UIKit

@IBDesignable class ButtonPrimary: UIView {

    @IBOutlet var button: UIView!

    override init(frame: CGRect) {
        super.init(frame: frame)
        initNib()
        setup()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initNib()
        setup()
    }

    func initNib() {
        let bundle = Bundle(for: ButtonPrimary.self)
        bundle.loadNibNamed("ButtonPrimary", owner: self, options: nil)
        addSubview(button)
        button.frame = bounds
        button.autoresizingMask = [.flexibleHeight, .flexibleWidth]
    }

    func setup() {
        self.backgroundColor = UIColor.clear
    }
}

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

您尝试了哪些变通办法?

我遇到了同样的问题,并将此解决方法添加到我的Podfile中,为我修复了它。我找到了解决方法here

# Workaround for Cocoapods issue #7606
post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
        config.build_settings.delete('CODE_SIGNING_ALLOWED')
        config.build_settings.delete('CODE_SIGNING_REQUIRED')
    end
end

它会从您的Pod中删除CODE_SIGNING_ALLOWEDCODE_SIGNING_REQUIRED构建设置。