我正在尝试将应用程序上传到 TestFlight。该应用程序在模拟器中编译和运行,如果我直接从 Xcode 安装它,它也将在我的 iPhone 上运行。如果我将其存档并推送到 TestFlight,然后从 TestFlight 更新我的设备,当我尝试查看特定视图控制器时应用程序崩溃。
我正在使用 MessageKit(使用 Cocoapods,因为这是我正在恢复的旧项目),并且使应用程序崩溃的特定视图控制器扩展了 MessagesViewController。 TestFlight 反馈给我的错误信息是:
“MessageKit:静态 UIColor.colorFromAssetBundle(命名:)”
也许归档过程正在跳过 Xcode 将在本地包含的 Messagekit 包?
在 StackOverflow 上对此类错误的任何引用似乎都非常具体:
如果通过 Xcode 安装 iOS 应用程序运行良好,但通过 TestFlight 安装时在一个特定的视图控制器上崩溃
对于上述用户,他们最终只是重写了 viewController(对我来说这意味着删除并重写 MessageKit)。
我认为这是归档过程跳过文件的问题。如果有任何关于如何调查这种情况的想法,或任何关于如何纠正这种情况的建议,我们将不胜感激。谢谢!
MessageKit 中的 UIColor 和 Bundle 扩展中提供了以下代码:
UIColor+Extensions.swift
private static func colorFromAssetBundle(named: String) -> UIColor {
guard let color = UIColor(named: named, in: Bundle.messageKitAssetBundle, compatibleWith: nil) else {
fatalError(MessageKitError.couldNotFindColorAsset)
}
return color
}
static var incomingMessageBackground: UIColor { colorFromAssetBundle(named: "incomingMessageBackground") }
Bundle+Extensions.swift
internal extension Bundle {
#if IS_SPM
static var messageKitAssetBundle: Bundle = Bundle.module
#else
static var messageKitAssetBundle: Bundle {
return Bundle(for: MessagesViewController.self)
}
#endif
}
确保您在此处拥有正确的 MessagesViewController 包或 手动将 MessageKit 中的assets 文件复制到项目的资产文件中。