ios - Xcode - IB 可设计 : Failed to render and update auto layout (no suitable image found)

标签 ios swift xcode xib ibdesignable

我正在尝试从 .xib 文件实现自定义 UIView,我希望能够在我的 Storyboard之一中检查该文件。但是,我收到构建时错误:

IB Designables: Failed to render and update auto layout status for LoginViewController (BYZ-38-t0r): dlopen(App.app, 1): no suitable image found. Did find: App.app: can't map unslidable segment __TEXT to 0x100000000 with size 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
    }
}

有什么想法吗?

最佳答案

您尝试过哪些解决方法?

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

关于ios - Xcode - IB 可设计 : Failed to render and update auto layout (no suitable image found),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50887371/

相关文章:

ios - 从 Action 中调用类共享函数

swift - 开关语句 : converting from if-statement to switch statement in swift

ios - Apple Watch 模拟器无法启动

ios - 如何在 launchScreen 之后建立引导?

ios - 如何在iOS cocos2d中无限移动背景图片

ios - 在 iOS 上使用具有文件完整性的 NSURLSession 批量下载文件

swift - 字典引用不更新字典

ios - 音频结束时更改按钮 Xcode

ios - C 风格的 for 语句已弃用,将来会被删除

ios - 如何同时支持纵向和横向模式 - XIB 的可重用 View