R.swift icon indicating copy to clipboard operation
R.swift copied to clipboard

Add R.info for static typing Info.plist

Open tomlokhorst opened this issue 6 years ago • 3 comments

The Info.plist file contains data that is sometimes needed at runtime. In particular, for Siri Shortcuts, I'm interested in the NSUserActivityTypes array.

We should add a top level R.info object, that includes relevant fields like userActivityTypes, but also things like applicationShortcutItems, as mentioned in https://github.com/mac-cain13/R.swift/issues/82

Example usage:

let myOrder: String = R.info.userActivityTypes.comMyAppViewOrder
let barcodeScanner: String = R.info.applicationShortcutItems.comMyAppBarcodeScanner.title

tomlokhorst avatar Jun 07 '18 14:06 tomlokhorst

Found this list of keys that you can have in a plist, could be a good starting point/reference: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html

Apple states it's not up to date, but I see keys stated as iOS 11.0 and later. So it doesn't seem that outdated yet...

Also; think we can use the regular identifier conversion we always use, and from there see if we want to automatically drop the NS and UI prefixes for example.

mac-cain13 avatar Jun 18 '18 06:06 mac-cain13

Just noticed that what file will be used as the Info.plist is a build setting. So you can use another plist in debug or release for example. That would make it a bit harder to do this right, we should think about that.

mac-cain13 avatar Jun 23 '18 13:06 mac-cain13

Could we merge the different info.plist files, in the same way we do for different translations of a strings file? If a key doesn't exist in both files, it would emit a warning.

tomlokhorst avatar Jun 23 '18 14:06 tomlokhorst