blog
Ottorino Bruni  

How to localize info.plist in Xcode

As you know with iOS 14 Apple requires consent to access the IDFA (Identifier for Advertisers), you need to display the App Tracking Transparency authorization request for accessing the IDFA. How to implement this change? Just update your Info.plist and add the NSUserTrackingUsageDescription key with a custom message describing your usage. My app supports more languages and the info.plist file is only one… ????

How to localize info.plist in Xcode ?

<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>

I read a lot of articles about automatically localize the info.plist file but i had several problems. The easiest solution was to:

  • Add in the project a new Strings file InfoPlist.strings (case sensitive), I’ve already written it but I want to repeat it otherwise it won’t work. You need to create the InfoPlist.strings file, not Infoplist.strings or infoPlist.strings.
  • Open the InfoPlist.strings file and add your keys and custom descriptions.
"NSUserTrackingUsageDescription" = "My app will use this identifier to provide you with personalized ads.";
  • Select the InfoPlist.strings and use the Localization section in the File Inspector to localize the file. Press the Localize… button to add additional Localizations to your app.
  • Run the simulator in each languages and this will work ????

Where is the info.plist in Xcode 13 for SwiftUI Project?

In Xcode 13 for SwiftUI projects, Apple took a fresh approach, ditching separate Info.plist files for a cleaner setup. Unlike before, where we had to manually mess with entitlements and Info.plist, now, things are simplified. Common settings, like the app name, have shifted to the target’s Info tab.

Where is the info.plist in Xcode 13 for SwiftUI Project?

After making changes, Xcode automatically integrates the Info.plist file into the project, showcasing it in the project navigator. For instance, when adding NSUserTrackingUsageDescription in the Info tab, Xcode generates an Info.plist file containing only the specified NSUserTrackingUsageDescription.

These settings can be adjusted in either location, and theoretically Xcode should synchronize both sets of configurations.

As highlighted in the Xcode 13 Release Notes:

Projects created from several templates no longer require configuration files such as entitlements and Info.plist files. Configure common fields in the target’s Info tab, and build settings in the project editor. These files are added to the project when additional fields are used. (68254857)

If you think your friends/network would find this useful, please share it with them. I’d really appreciate it.

Thanks for reading! ????

 

Reference: About Information Property List Files

🚀 Discover CodeSwissKnife, your all-in-one, offline toolkit for developers!

Click to explore CodeSwissKnife 👉

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.