App crashes at launch on missing symbol AVPlayerView... except on first launch

I don't know what triggered this in a previously-running application I'm developing: When I have the build target set to "My Mac (designed for iPad)," I now must delete all the app's build materials under DerivedData to get the app to build and run exactly once. Cleaning isn't enough; I have to delete everything.

On second launch, it will crash without even getting to the instantiation of the application class. None of my code executes.

Also: If I then set my iPhone as the build target, the app will build and run repeatedly. If I then return to "My Mac (designed for iPad)," the app will again launch once and then crash on every subsequent launch.

The crash is the same every time:

dyld[3875]: Symbol not found: _OBJC_CLASS_$_AVPlayerView
  Referenced from: <D566512D-CAB4-3EA6-9B87-DBD15C6E71B3> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Debugger/libViewDebuggerSupport.dylib
  Expected in:     <4C34313C-03AD-32EB-8722-8A77C64AB959> /System/iOSSupport/System/Library/Frameworks/AVKit.framework/Versions/A/AVKit

Interestingly, I haven't found any similar online reports that mention this symbol.

Has anyone seen this behavior before, where the crash only happens after the first run... and gets reset when you toggle the target type?

Hi @Stokestack , really strange behaviour.

AVPlayerView is really an old view present on AVkit on Mac OS 10.9, and it is used on QuickTime App itself. https://developer.apple.com/documentation/avkit/avplayerview

If you can generate some sort of sample project and tell which is your enviromment, probably could help. Error simply tell that no AVPlayerView is found on Mac OS, that is really strange

Bye Rob

Hello @Stokestack, thank you for your post. I suspect the issue is due to the fact that AVPlayerView is only available on macOS. On iOS and iPadOS, you would use AVPlayerViewController instead. In addition, VideoPlayer is a SwiftUI View that is available on both macOS and iOS/iPadOS, so might be a more suitable option.

As @GRALInfo mentioned, if you are able to share a test project, that'd be great. You can find tips on creating and sharing a test project in Creating a Test Project.

Hi @Engineer @Stokestack , as @Engineer mentioned, it could be a issue on iOS side. If this is the use case, @Stokestack , you should wrap piece of code using AVPlayerView with this conditional compilation :

// Swift  
#if targetEnvironment(macCatalyst)
    // Code specific to Mac.
#else
    // Code to exclude from Mac.
#endif
// Objective C
#if TARGET_OS_MACCATALYST
    // Code specific to Mac.
#else
    // Code to exclude from Mac.
#endif

Bye Rob

Thanks guys. But I'm not using AVPlayerView! That string doesn't even occur in my source, or in DerivedData.

I can't post my entire project. I'll see if I can reproduce it with a basic test one.

I just had the exact same problem. I have not tried to run my iPhone App on the Mac for a month, but today I tried to for testing and it failed. It worked fine a month ago. In the last month I have updated the Mac OS to 15.1.1 (24B91) and I am using XCode Version 16.1 (16B40) deployment target is IOS 17.1 The iPhone has the latest Beta OS installed, but I am not using any new API in my code.

I am not using any video players in my app.

dyld[83622]: Symbol not found: OBJC_CLASS$_AVPlayerView Referenced from: <7D70BC8F-8276-33E5-964D-86BD04CC082F> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Debugger/libViewDebuggerSupport.dylib Expected in: <B1D8EA23-370D-3B45-81E0-7D5982262CCD> /System/iOSSupport/System/Library/Frameworks/AVKit.framework/Versions/A/AVKit Type: stdio

Any help would be appreciated. I don't even know where to begin to debug/fix this

In case others come here and don't look at the comments:

Apple has acknowledged this as a bug. Fortunately, there is a workaround:

Go to the scheme, say Edit Scheme. Go to Run (Debug) and find the checkbox for View Debugging and deactivate it.

But please file a Feedback on this. In it, you can refer to my report: FB15492822

App crashes at launch on missing symbol AVPlayerView... except on first launch
 
 
Q