AV PlayerView + Interface Builder + Archive Build Error

If you add an AVPlayerView into a window in your StoryBoard, it will hang your app on launch, but not in Xcode. Only in the release builds for the app store.


Here are the steps to reproduce:


1. Create a new storyboard project in Xcode.

2. Add AVKit Player View to your main window.

3. If you run the app from Xcode, everything works fine.

4. Build the archive version for deployment to the App Store.

5. Run the app from the archive. It freezes the window drawing process

6. If you add some debug code, you'll find it hangs in the loadView() of NSViewController of the default ViewController class. That method never exits.


If you look at the console output of the release build, you will see this message:


Failed to set (contentViewController) user defined inspected property on (NSWindow): *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (AVPlayerView) for key (NS.objects) because no class named "AVPlayerView" was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target). If the class was renamed, use setClassName:forClass: to add a class translation mapping to NSKeyedUnarchiver


For the Xcode debug build, you see this:


-[AVPlayerView initWithCoder:] 365 0x102031800


I noticed this problem when I was updating an app with a minor change, it worked just fine in Xcode, so I submitted it to the app store and it was rejected because of a blank screen.

Replies

Oh boy. This happened to me. I finally stumbled on my fix. Hope it helps you.

I added the AVKit.framework under Targets>app>General>Frameworks, Libraries, and Embedded Content.

When I built and ran app, it worked. I don't have a clue why just importing AVKit doesn't work.
The error is reporting that the class does not exist because AVKit.framework is not loaded. You can either explicitly included as described in another post:

Add AVKit.framework to
Code Block
Targets -> App -> General -> Frameworks, Libraries, and Embedded Content


Or you ensure
Code Block
Build Settings->Apple Clang - Language - Models -> Links Frameworks Automatically == YES
and add a direct code reference to a symbol in AVKit to trigger the loading along along with the AVKit import.