0

I am attempting to upload an app to TestFlight. The app compiles and runs in the simulator, and will also run on my iPhone if I install it direct from Xcode. If I archive and push it to TestFlight, then update my device from TestFlight, the app crashes when I attempt to view a specific view Controller.

I am using MessageKit (using Cocoapods, since this is an older project I am reviving), and the specific view Controller that crashes the app extends MessagesViewController. The error message that TestFlight kicks back to me reads:

"MessageKit: static UIColor.colorFromAssetBundle(named:)"

Perhaps the archiving process is skipping a bundle from Messagekit that Xcode will include locally?

Any references to an error like this on StackOverflow seem to be hyper specific:

iOS app runs fine if installed through Xcode, but crashes on one particular view controller when installed through TestFlight

and in the case of the above user, they just ended up re-writing the viewController (which for me would mean dropping and rewriting MessageKit).

I think this is an issue with the archiving process skipping files. Any thoughts on how to investigate if that is the case, or any suggestions on how to rectify this would be greatly appreciated. Thanks!

Chris Whipple
  • 395
  • 3
  • 13
  • Did you tried yo install using swift package manager instead of cocoapods ? Did you update to last version ? – Ptit Xav Mar 24 '23 at 21:16
  • Thanks for getting back to me. I reinstalled all the pods in my project hoping that would help, but no luck. I was holding off from updating the pod to a newer version, or switching to swift package manager, as a last resort, as that might have unintended consequences for the codebase. That is on the short list to try if an easier solution does not come out of this post. – Chris Whipple Mar 24 '23 at 23:44
  • Just a small question : did you stripped symbols from TestFlight ? This because the way the code work in this part is based on message kit view controller class. You could also try to find the asset bundles in message kit pod and copy these in your app . – Ptit Xav Mar 25 '23 at 19:19
  • @PtitXav Thanks for responding! I confirmed that the assets are in my local directory (...\Pods\MessageKit\resources\Assests), which I assumed was the case considering it DOES work when running locally on simulators or direct from Xcode. I am unsure of what you mean by "Stripped Symbols" from Testflight. Is that an option I can check during archiving? – Chris Whipple Mar 25 '23 at 23:55
  • I confirmed that "Strip Debug Symbols during Copy" is set to YES in my project. I am not sure what that does, should I try that with it set to NO? – Chris Whipple Mar 26 '23 at 00:19
  • 1
    When you said extend MessageViewController, did you mean that to add an extension or subclassed it ? as in the code the name of the class seems important. – Ptit Xav Mar 26 '23 at 10:36
  • So in this case it's basically that it can't find the colour in the bundle. When you install it via XCode did you try `release` build? – zaitsman Mar 27 '23 at 04:41
  • @zaitsman Yes, it was a release build – Chris Whipple Mar 28 '23 at 01:19

2 Answers2

0

The following codes are available in the UIColor and Bundle extensions in MessageKit:

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
}

Make sure you have the correct bundle for MessagesViewController here or Manually copy the assets files in MessageKit into the Project's assets file.

a.u.b
  • 1,589
  • 10
  • 25
  • Thanks for the answer! Unfortunately, I can confirm that these files and this code in particular is in the project already, and is working when running on a simulator through xcode, or if downloaded directly to a phone from xcode, so clearly the issue is these files are not getting packed up during archiving. Any suggestions? PtitXav suggested to look into stripped symbols in the comment above, not 100% sure what that means... – Chris Whipple Mar 25 '23 at 23:58
0

Solution: Coacopods was the issue. I was running the latest version of Messagekit that was published using cocaopods, which was over a year old. This meant that updating the pods was never going to work. I switched to swift package manager and have the up to date version of Messagekit, and everything is working! Thanks to everyone that reached out.

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

Chris Whipple
  • 395
  • 3
  • 13