sharing video using uiactivityViewcontroller
First get video file path
let videoURL = NSURL(fileURLWithPath:localVideoPath)
And then pass this path to UIActivityViewController
like below
let activityItems = [videoURL, "Check this out!" ]
let activityController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
activityController.popoverPresentationController?.sourceView = self.view
activityController.popoverPresentationController?.sourceRect = self.view.frame
self.presentViewController(activityController, animated: true, completion: nil)
Updated Code for Swift 4
let localVideoPath = "your_video_path_here..."
let videoURL = URL(fileURLWithPath: localVideoPath)
let activityItems: [Any] = [videoURL, "Check this out!"]
let activityController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
activityController.popoverPresentationController?.sourceView = view
activityController.popoverPresentationController?.sourceRect = view.frame
self.present(activityController, animated: true, completion: nil)
To share video from Local Document directory path
func shareVideo(videoPath : String){
let localVideoPath = videoPath
let videoURL = URL(fileURLWithPath: localVideoPath)
let activityItems: [AnyObject] = [videoURL as AnyObject]
let activityController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
activityController.popoverPresentationController?.sourceView = view
activityController.popoverPresentationController?.sourceRect = view.frame
self.present(activityController, animated: true, completion: nil)
}