我正在尝试从 .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_ALLOWED
和 CODE_SIGNING_REQUIRED
build设置。
关于ios - Xcode - IB 可设计 : Failed to render and update auto layout (no suitable image found),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50887371/