8

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.

1 Answer 1

19

The answer is to add AVKit.framework manually to Link Binary With Libraries in the app target's Build Phases in Xcode.

Link AVKit Framework with Libraries

It turns out the SwiftUI AVKit's VideoPlayer view is nil in the archived app, presumably not linked or built with AVKit.

This blog post is the source: Source. All credit to Javier at The SwiftUI Lab. Surprisingly, the issue seems to be present since around June 2020.

Bug Report: FB8928032

Sign up to request clarification or add additional context in comments.

3 Comments

This issue is still present as of July 2024, and also happens for extensions. For example: Safari App Extension. This solution worked perfectly, thanks!
Thank you for your solution—this app crash was super hard to debug and has cost me more time of my life than I’d like to admit.
Still exists in late 2025!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.