I am using the UIImagePickerController in two cases
In the first
Swift 4 solution that works for me to get the url of last image in Photo Library:
let fetchOptions = PHFetchOptions()
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]
let fetchResult = PHAsset.fetchAssets(with: .image, options: fetchOptions).lastObject
PHImageManager().requestAVAsset(forVideo: fetchResult!, options: nil, resultHandler { (avurlAsset, _, _) in
if let newObj = avurlAsset as? AVURLAsset {
print(newObj.url)
}
})
Hope it helps!