如何修复警告 "CoreUI: RunTimeThemeRefForBundleIdentifierAndName() couldn't find Assets.car in bundle with identifier: '(null)'"?

How to fix warning "CoreUI: RunTimeThemeRefForBundleIdentifierAndName() couldn't find Assets.car in bundle with identifier: '(null)'"?

我正在尝试在 iOS 13 测试版上测试应用程序。当我在欢迎屏幕上点击一个按钮以转到另一个屏幕时,应用程序会冻结然后终止。当我在 Xcode 11 中调试时,我在控制台中看到以下警告行:

[framework] CoreUI: RunTimeThemeRefForBundleIdentifierAndName() couldn't find Assets.car in bundle with identifier: '(null)'

[framework] CoreUI: RunTimeThemeRefForBundleIdentifierAndName() couldn't find Assets.car in bundle with identifier: '(null)'

几秒钟后,应用程序终止并显示日志条目:

Message from debugger: Terminated due to memory issue

关于iOS12就没有这个问题。我用几个资产文件创建了一个简单的测试应用程序,按钮点击上的 segue 工作正常。另外我把目标版本改成iOS 13,改了bundle identifier,清理重建,问题还是出现

我发现问题与

无关

CoreUI: RunTimeThemeRefForBundleIdentifierAndName() couldn't find Assets.car in bundle with identifier: '(null)'

在目标屏幕上使用了自定义 UILabel。应用程序冻结和内存问题的根本原因是其方法之间的可重入循环

override var text: String? {
    didSet {
        guard let text = text else { return }
        let textRange = NSMakeRange(0, text.count)
        // Kern attribute needed to do letter spacing over text
        let attributedText = NSMutableAttributedString(string: text)
        attributedText.addAttribute(NSAttributedStringKey.kern , value: 2.0, range: textRange)
        // Add other attributes if needed
        self.attributedText = attributedText
    }
}

override public func layoutSubviews() {
    super.layoutSubviews()
    if let text = self.text {
        self.text = text.uppercased()
    }
}

可能新的 SDK 版本在 attributedText 字段已更改时调用 layoutSubviews()

要解决此问题,只需转到目标的构建阶段,然后删除 Assets.xcasset 并重新添加它