3

I have a ${PRODUCT_NAME} in order to reference app name for all my targets. I want to use it in the InfoPlist.strings for using target name in the CameraUsageDescription and other descriptions.

How can I use it in the string?

Something like this:

/* Localized versions of Info.plist keys */

"NSLocationWhenInUseUsageDescription" = "Allows geolocation to send your location in the chat or know which institutions and services are near you";
"NSContactsUsageDescription" = "To be able to talk with the contacts who have ${PRODUCT_NAME} we need to access your agenda";
"NSPhotoLibraryUsageDescription" = 'Allows ${PRODUCT_NAME} to access the gallery to be able to send photos through the chat';
"NSCameraUsageDescription" = "Allows access to the camera to make a photo and send it";
"NSContactsUsageDescription" = "To be able to talk with the contacts who have ${PRODUCT_NAME} we need to access your agenda";
"NSPhotoLibraryAddUsageDescription" = "Allows access to save the images received by the chat";
il3v
  • 472
  • 4
  • 15
Javier Torron Diaz
  • 347
  • 1
  • 4
  • 25

1 Answers1

0

You can use $(PRODUCT_NAME) to ref. app name in info.plist.

For example: "$(PRODUCT_NAME) requires camera permission."

It will come like "YourAppName requires camera permission."

Jouby
  • 2,196
  • 2
  • 21
  • 33
  • I am using InfoPlist.strings, so the response to this method (I had checked It yesterday) is: "$(PRODUCT_NAME)Allows geolocation to send your location in the chat or know which institutions and services are near you" . – Javier Torron Diaz Aug 14 '18 at 07:22
  • @LordVermiis i didn't get your point. Is this resolved or still in vein? If not resolved please elaborate in details. – Bikramjeet Singh Aug 14 '18 at 08:00
  • Sorry, I did not explain properly. That did not work, because the modal ask for permission dont shows the PRODUCT_NAME value, show exactly $(PRODUCT_NAME) as literal. Is not solved. What I mean is that using this formula dont translates $(PRODUCT_NAME) to its value – Javier Torron Diaz Aug 14 '18 at 08:28
  • I have created a sample app to show you how localization works with .plist files. I have localized .plist to french language as well as english. Test Case: Change your device language to french or english and run the sample project. PS: You need to uninstall app every-time you run it as permission pop-ups only come once. Link to sample app : https://files.fm/u/7fw3zwf9 Please up-vote if i have helped you out in any way. Thank you :) – Bikramjeet Singh Aug 14 '18 at 09:55
  • @LordVermiis Have u checked the sample app? – Bikramjeet Singh Aug 16 '18 at 04:42
  • Sorry @bikramjeet-singh, I have been in a hospital this days and I have been very far from a computer. I will test it today, thanks a lot. – Javier Torron Diaz Aug 20 '18 at 06:24
  • I have tested it It works for sure, but it is not what I asked for. You used `info.plist` files localized what Is correct, but, In my project, I have `InfoPlist.strings` files, which are localized. In this `InfoPlist.strings` the code `$(PROCUDT_NAME)` is shown as a literal string. – Javier Torron Diaz Aug 20 '18 at 06:36
  • See this [example](https://stackoverflow.com/questions/25736700/how-to-localise-a-string-inside-the-ios-info-plist-file) to view how to use the InfoPlist.strings – Javier Torron Diaz Aug 20 '18 at 06:40
  • I think if you want to use $(PRODUCT_NAME) you may want to use this approach. If you found anything other than this then do let me know too. :) – Bikramjeet Singh Aug 20 '18 at 06:48
  • Sure, I will tell you. Thanks a lot. – Javier Torron Diaz Aug 20 '18 at 06:54
  • Hi guys, is this thread open? because i also want to use product name dynamically in infoPlist.string file. Something like this NSCameraUsageDescription= ${PRODUCT_NAME}+"カメラへのアクセス"; so this will change my app name for every target and rest will be same. is it possible ? Any solutions is appreciated . Thanks – Shrikant Phadke Mar 12 '20 at 03:00