【问题标题】:Xcode - IB Designable: Failed to render and update auto layout (no suitable image found)Xcode - IB Designable:无法渲染和更新自动布局(找不到合适的图像)
【发布时间】:2018-06-16 11:10:52
【问题描述】:

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

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

我正在使用 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
    }
}

有什么想法吗?

【问题讨论】:

    标签: ios swift xcode xib ibdesignable


    【解决方案1】:

    您尝试了哪些解决方法?

    我遇到了同样的问题,将这个解决方法添加到我的 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 构建设置。

    【讨论】:

    • 是的,我确实尝试过那个,以及其他一些解决方法。但据我了解,解决方法仅适用于 CocoaPods 1.5,所以我想降级它会解决任何最终问题?
    猜你喜欢
    • 2018-11-10
    • 2018-03-25
    • 2017-02-05
    • 1970-01-01
    • 1970-01-01
    • 2020-06-29
    • 2019-11-17
    • 1970-01-01
    相关资源
    最近更新 更多