如果直接从 Xcode 上传 iOS 应用程序运行成功,如果从 TestFlight 更新则崩溃。捆绑包未包含在存档中?

问题描述 投票:0回答:2

我正在尝试将应用程序上传到 TestFlight。该应用程序在模拟器中编译和运行,如果我直接从 Xcode 安装它,它也将在我的 iPhone 上运行。如果我将其存档并推送到 TestFlight,然后从 TestFlight 更新我的设备,当我尝试查看特定视图控制器时应用程序崩溃。

我正在使用 MessageKit(使用 Cocoapods,因为这是我正在恢复的旧项目),并且使应用程序崩溃的特定视图控制器扩展了 MessagesViewController。 TestFlight 反馈给我的错误信息是:

“MessageKit:静态 UIColor.colorFromAssetBundle(命名:)”

也许归档过程正在跳过 Xcode 将在本地包含的 Messagekit 包?

在 StackOverflow 上对此类错误的任何引用似乎都非常具体:

如果通过 Xcode 安装 iOS 应用程序运行良好,但通过 TestFlight 安装时在一个特定的视图控制器上崩溃

对于上述用户,他们最终只是重写了 viewController(对我来说这意味着删除并重写 MessageKit)。

我认为这是归档过程跳过文件的问题。如果有任何关于如何调查这种情况的想法,或任何关于如何纠正这种情况的建议,我们将不胜感激。谢谢!

ios swift xcode testflight messagekit
2个回答
0
投票

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 文件复制到项目的资产文件中。


0
投票
解决方案:Coacopods 是问题所在。我运行的是使用 cocaopods 发布的最新版本的 Messagekit,它已经存在一年多了。这意味着更新 pod 永远不会起作用。我切换到 swift 包管理器并拥有最新版本的 Messagekit,一切正常!感谢所有伸出援手的人。

参考:

https://github.com/MessageKit/MessageKit/issues/1537

© www.soinside.com 2019 - 2024. All rights reserved.