In brief, my macOS app written purely in SwiftUI uses VideoPlayer to present a locally stored video (not bundled). The pertinent code is as follows:
import SwiftUI
import AVKit
struct CustomizedPlayerView: View {
@State var player: AVPlayer?
var body: some View {
VStack {
if let avPlayer = self.player {
VideoPlayer(player: avPlayer).frame(minWidth: 320, minHeight: 320)
}
Text("Problematic VideoPlayer View")
}
}
}
When building for development in Xcode, there are no issues (no crashes, no issues playing).
However, opening the view in the notarized app, causes the entire app to crash with Exception Type: EXC_CRASH (SIGABRT)
. This signals to me that the system is aborting my app because of an improper assignment of a nil value, but the player does seem to pass a non-nil value at the time of crash.
I figured out the issue after some debugging and researching. I wanted to share what worked for me and hope it will save someone time.