OlivierLDff / QtIosCMake

📱 Deploy Qt Application for iOS with a single macro when using CMake.
BSD 3-Clause "New" or "Revised" License
58 stars 15 forks source link

✨ Add support for NSPhotoLibraryUsageDescription #16

Closed FransRosencrantz closed 3 years ago

FransRosencrantz commented 3 years ago
FransRosencrantz commented 3 years ago

@OlivierLDff Hmm I just saw that there are many different Cocoa Keys https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html In our project, we just need one of these keys "NSPhotoLibraryUsageDescription" but maybe you don't want to have just one of these variables in the repo? In that case, do you have a better idea to add it? Combining the custom list with the generated? maybe?

OlivierLDff commented 3 years ago

The idea is for you to copy the Info.plist.in inside your project and provide it via CUSTOM_PLIST. That way you can add all the keys you need in it. It can be interesting for QtIosCMake to already come with couple of common key. I believe that accessing photo library is standard use case.

Maybe there is a smart way to add a lot of keys. But it would require more cmake code. Maybe add a COCOA_KEYS input, that expect a list of key. COCOA_KEYS ${MY_KEY_1} ${MY_KEY_2}

Key could be created like that:

set(MY_KEY_1 MyKey1)
set(${MY_KEY_1}_TYPE "string")
set(${MY_KEY_1}_KEY "NSPhotoLibraryUsageDescription")
set(${MY_KEY_1}_DESCRIPTION "My Description")

Which could be wrapped into a function qt_ios_create_string_key, and then also do a function qt_ios_create_bool_key, etc... for every keys.

Then in QtIosCMake simply loop on each key and append into a string EXTRA_KEYS that will go in Info.plist.in.

This is doable quite easily, but i need a project with already a bunch of keys to tests/debug/compare result and see what is expected.

I haven't used lots of cocoa keys yet.

Anyway for now i can just merge your PR that is common key, i will see later to add something smart.

OlivierLDff commented 3 years ago

Thanks for the PR !