To avoid wasting a URL to the digital camera roll in Swift, you need to use the Images framework, which supplies a approach to work together with the consumer’s picture library
import Images
func saveURLToCameraRoll(url: URL, completion: @escaping (Error?) -> Void) {
PHPhotoLibrary.shared().performChanges({
let request = PHAssetCreationRequest.forAsset()
let choices = PHAssetResourceCreationOptions()
choices.originalFilename = url.lastPathComponent
request.addResource(with: .picture, fileURL: url, choices: choices)
}) { success, error in
if success {
completion(nil)
} else {
completion(error)
}
}
}