I need to get the thumbnail of the chosen video. When testing on the simulator, everything is fine.
But when testing on my own iPhone with iOS 17, I get the error:
“…you don’t have permission to view it”.
Please, would anyone know why this private path is returned when testing on the device?
I researched some things a little, and found relationships with App Sandbox & Entitlements, but I’m still researching and learning more about it.
The code:
guard results.count > 0 else { return }
for asset in results {
if asset.itemProvider.hasItemConformingToTypeIdentifier(UTType.movie.identifier) {
asset.itemProvider.loadItem(forTypeIdentifier: UTType.movie.identifier) { [weak self] movie, _ in
guard let self, let url = movie as? NSURL, let _movie: String = url.absoluteString else { return }
print(movie)
...
file:///private/var/mobile/Containers/Shared/AppGroup/.../&type=3&mode=2&loc=true&cap=true.mov
The thumbnail code: When trying to get the video thumbnail with the above result
extension URL {
func thumbnailForMovie() throws -> UIImage? {
do {
let _asset = AVURLAsset(url: self, options: nil)
let generatorImage = AVAssetImageGenerator(asset: _asset)
generatorImage.appliesPreferredTrackTransform = true
let timestamp = _asset.duration
let cgImage = try generatorImage.copyCGImage(at: timestamp, actualTime: nil)
let _thumbnail = UIImage(cgImage: cgImage)
return _thumbnail
} catch {
throw error ....
If anyone can help me!! Thanks.




