Share Extension can access files from the Photos app but not the Files app

Share Extension can access files from the Photos app but not the Files app. In case of the Photos app the file url is something like file:///var/mobile/... In case of the Files app the url stars with file:///private/var/mobile/... The following error is thrown in case of the Files app

Error Domain=NSCocoaErrorDomain Code=260 "The file “file.pdf” couldn’t be opened because there is no such file."

However the file is there, it was selected via the Files app and the share button was used to launch the Share Extension.

Also the access to the file is within the following block

url.startAccessingSecurityScopedResource()
...
url.stopAccessingSecurityScopedResource()

Another issue is that the Share Extension does not appear in the Settings / Privacy / Files and Folders. Here are the apps which have the "Applications that have requested access to files and folders will appear here".

What is the solution to allow the Share extension access the files from the Files app ?

Share Extension can access files from the Photos app but not the Files app
 
 
Q