我有一个自定义视图中的代码:
class AView: UIView {
func setup {
Bundle.main.loadNibNamed("\(Self.self)", owner: self, options: nil)
}
}我希望这会用AView加载nib文件名,它在调试模式下工作没有问题。但是当在发布模式下运行时,它会崩溃。
错误消息为:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: '_TtC10ATPlatformP33_BB740EC0B8824C2F1932C467ED63DEF214LanguageBundle </private/var/containers/Bundle/Application/B0094397-EC2C-4550-8981-0CF2DCFB580C/xxx.app> (loaded)' with name 'Self''这意味着"\(Self.self)"返回了Self字符串。
我意识到的是,当将Swift Compiler - Code Generation -> Optimization Level设置为[-Onone]时,它不会崩溃。
有人知道为什么吗?
https://stackoverflow.com/questions/68661175
复制相似问题