Experimenting with creating a simple app to play video on the iPhone (Xcode 7.3, swift iOS9) and I'm just trying to get the player to appear before adding code to load content.
Using storyboard, created a button and segue (show) to an AVViewController object. When app is run on device and button is pressed, I get:
"Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named AVPlayerViewController' "
Prior to declaring my ViewContrller: UIViewController class I have: import UIKit, import AVKit and import AVFoundation. What's missing? I suspect something else I need to import but my research has only turned up AVKit and AVFoundation as necessary.
I found a solution while viewing answers to other similar problems here on Stack Overflow.
To allow the app to run correctly I had to manually link the frameworks to my project.
In Xcode I clicked on my project's name to get to settings, then added AVFoundation.framework and AVKit.framework in the Linked Frameworks and Libraries section. Now running the app allowed me to instantiate a AVPlayerViewController object without any problems. Apparently, importing AVKit and AVFoundation in my code was not enough. Anyone know why I had to explicitly link the frameworks?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With