How should qt for ios open a photo album or select an image file for processing?
-
Hi,
The iOS platform notes give a hint for that.
-
The platform notes are clearly not enough as for iOS >= 17 and in 2024.
The provided native image picker that you got with a QFileDialog pointing to QStandardPath::standardLocations(QStandardPath::PicturesLocation).last()
(which is btw. assets-library://)
is returning a list with a single entry on the selected image like
assets-library://asset/asset.JPG?id=ED7AC....4f2ED&ext=JPG
(needed to have the QTs iOS Plugin linked by having 'QTPLUGIN += qiosnsphotolibrarysupport' passed to qmake to get it working for me)Now since I have at least the native picker and some hint on the selected file, every attempt to list the content of 'assets-library://' or read any reformatted version of the provided file path (altering the url format) is either returning an empty folder or crashes the QFileInfo if accessing it in some ways without further information.
Having some hints on the deprecation of the assets-library https://developer.apple.com/documentation/assetslibrary while still getting this path returned, i believe the QT plugin might be deprecated too? (using 5.15.16)
I think the plugins code needs to use PhotoKit backend https://developer.apple.com/documentation/photokit/selecting_photos_and_videos_in_ios -
@p_zirker hi,
Did you set the NSPhotoLibraryUsageDescription entry in your .pro file ? It should trigger the plugin addition.
That said, you should bring your deprecation analysis to the bug report system. This will allow for the adequate people to be pinged about it.
-
The NSPhotoLibraryUsageDescription entry of info.plist is in the platform notes, so yes, this is done. Missing it, the Native Image Picker is not appearing. Made a Ticket to the Bug report. Designwise it should be considered to get away from a self edited inof.plist and have all entries provided through cmake/qmake. In that case, the plugins can add such entries by themself with no further remarks. Thanks for your Work @SGaist, served me a lot over the years, but iOS is playing in its own league of pita!
-
You could write a feature request for that. CMake has a limited support for handling that file but AFAIK, nothing as complete as you would need.
Thanks for your kind words.