AVKit VideoPlayer unable to run after archive on macOS 11.01

Step to reproduce:
Code Block swift
struct ContentView: View {
  var body: some View {
    VideoPlayer(player: AVPlayer(url: URL(string: "https://bit.ly/swswift")!))    .frame(width: 400, height: 400, alignment: .center)
  }
}

2. Archive
3. Double click to Launch App

crash log
Code Block language
Process: AVDemo [7017]
Path: /Users/USER/*/AVDemo.app/Contents/MacOS/AVDemo
Identifier: com.yjaqen.AVDemo
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: AVDemo [7017]
User ID: 501
Date/Time: 2020-11-17 12:11:21.747 +0800
OS Version: macOS 11.0.1 (20B29)
Report Version: 12
Bridge OS Version: 5.0.1 (18P2561)
Anonymous UUID: E5A28A36-1BC0-C37D-6165-74C06F97BC40
Sleep/Wake UUID: 9A558204-312A-411C-89AE-F584CB9802F9
Time Awake Since Boot: 11000 seconds
Time Since Wake: 11000 seconds
System Integrity Protection: disabled
Crashed Thread: 8 Dispatch queue: com.apple.root.utility-qos
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
failed to demangle superclass of VideoPlayerView from mangled name 'So12AVPlayerViewC'
abort() called
Thread 0:: Dispatch queue: com.apple.main-thread
...
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 2
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 9163771
thread_create: 8
thread_set_state: 3273
VM Region Summary:
ReadOnly portion of Libraries: Total=833.8M resident=0K(0%) swapped_out_or_unallocated=833.8M(100%)
Writable regions: Total=625.7M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=625.7M(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Accelerate framework 128K 1
Activity Tracing 256K 1
CG backing stores 3240K 6
CG raster data 40K 2
CoreAnimation 552K 15
CoreGraphics 12K 2
CoreServices 4K 1
CoreUI image data 1232K 9
Foundation 16K 1
Kernel Alloc Once 8K 1
MALLOC 224.1M 53
MALLOC guard page 32K 8
MALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)
STACK GUARD 56.0M 10
Stack 12.6M 10
VM_ALLOCATE 2392K 35
CTF 759 1
DATA 16.5M 397
DATA_CONST 20.8M 248
DATA_DIRTY 1206K 139
FONT_DATA 4K 1
LINKEDIT 483.9M 6
OBJC_RO 61.0M 1
OBJC_RW 2468K 2
TEXT 350.0M 402
UNICODE 588K 1
mapped file 229.9M 25
shared memory 40K 4
=========== ======= =======
TOTAL 1.8G 1383
TOTAL, minus reserved VM space 1.4G 1383
Model: MacBookPro15,2, BootROM 1554.50.3.0.0 (iBridge: 18.16.12561.0.0,0), 4 processors, Quad-Core Intel Core i5, 2.3 GHz, 16 GB, SMC
Graphics: kHW_IntelIrisGraphics655Item, Intel Iris Plus Graphics 655, spdisplays_builtin
Memory Module: BANK 0/ChannelA-DIMM0, 8 GB, LPDDR3, 2133 MHz, Micron, -
Memory Module: BANK 2/ChannelB-DIMM0, 8 GB, LPDDR3, 2133 MHz, Micron, -
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x7BF), wl0: Sep 11 2020 16:57:49 version 9.30.440.2.32.5.61 FWID 01-129bddb
Bluetooth: Version 8.0.1f5, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB 3.1 Bus
USB Device: Apple T2 Bus
USB Device: Touch Bar Backlight
USB Device: Touch Bar Display
USB Device: Apple Internal Keyboard / Trackpad
USB Device: Headset
USB Device: Ambient Light Sensor
USB Device: FaceTime HD Camera (Built-in)
USB Device: Apple T2 Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 47.4
Thunderbolt Bus: MacBook Pro, Apple Inc., 47.4



same problem here
The problem is not related to archiving. It occurs when the you launch the app in non-debug mode, which happens to be the case for Archive. But other ways to see the crash are, launching the executable from Finder (doesn't have to be the one archived), or uncheck the "Debug Executable" option in your the "Run" profile of your active scheme in Xcode.

I found a workaround, which is effective, but seems completely unrelated. This crash does not occur, if at some point before you display the VideoPlayer, an NSTextArea is displayed. But not just any NSTextArea. It must be loaded with an RTFD document. But not just any document, one that contains an image!

More details can be found here: swiftui-lab.com/videoplayer-bug
I had the same issue. I resolved it by adding the AVKit.framework (Do Not Embed) under the "Frameworks, Libraries, and Embedded Content" section at the Target

Thanks @lucienkerlWIT, that worked for me also. So strange it isn't required for debug builds.

I ran into this issue as well. Adding the AVKit framework fixed it. Thanks to @lucienkerlWIT for the great solution.

Not working for me unfortunately.

OMG, I spent days trying to figure this out. Thanks, AVKit framework works!

AVKit VideoPlayer unable to run after archive on macOS 11.01
 
 
Q