Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Empty Display Name on Xcode

Discussion in 'Localization Tools' started by pabloivme, Apr 29, 2022.

  1. pabloivme

    pabloivme

    Joined:
    Oct 23, 2016
    Posts:
    4
    Is it normal that "Display Name" is empty after adding the "iOS App Info" on Localization Settings? It works when the app is deployed to the phone, but it shows empty on Xcode. Thanks.

    upload_2022-4-29_11-1-56.png

    upload_2022-4-29_11-1-40.png
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    Yes from what I can recall the value is in a different info.plist file.
     
    pabloivme likes this.
  3. elaine_unity694

    elaine_unity694

    Joined:
    Oct 12, 2020
    Posts:
    26
    Hi, my previous project was showing empty in "Bundle Display Name" from info.plist file and was able to released to App Store.
    But now I use the same method for my new project and I get a warning message from Apple

    We identified one or more issues with a recent delivery for your app, MY_APP_NAME. Your delivery was successful, but you may wish to correct the following issues in your next delivery:
    ITMS-90784: Missing bundle name - The CFBundleName and CFBundleDisplayName Info.plist keys are missing or have empty values in the bundle with MY_BUNDLE_ID bundle ID.


    Could you assist me please ?
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    You will need to manually edit the info.plist file to give it default values. We have fixed this in the next release.
     
    elaine_unity694 likes this.
  5. elaine_unity694

    elaine_unity694

    Joined:
    Oct 12, 2020
    Posts:
    26
    Thanks for clarifying.

    But I am using Unity Cloud Build, may I know how to add it default values please ?
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    You can't. You would need to modify the localization package code.
    Move the localization package from the package cache into the projects Packages folder.
    Now replace the script Editor/Platform/iOS/Player.cs contents with this:

    Code (csharp):
    1. #if UNITY_IOS || UNITY_IPHONE
    2. using System;
    3. using System.IO;
    4. using System.Text;
    5. using UnityEditor.iOS.Xcode;
    6. using UnityEditor.Localization.Platform.Utility;
    7. using UnityEngine.Localization;
    8. using UnityEngine.Localization.Platform.iOS;
    9. using UnityEngine.Localization.Settings;
    10. using UnityEngine.Localization.Tables;
    11. using Debug = UnityEngine.Debug;
    12.  
    13. namespace UnityEditor.Localization.Platform.iOS
    14. {
    15.    public static class Player
    16.    {
    17.        const string k_InfoFile = "InfoPlist.strings";
    18.  
    19.        static PackageManager.PackageInfo s_PackageInfo;
    20.        static PackageManager.PackageInfo LocalizationPackageInfo
    21.        {
    22.            get
    23.            {
    24.                if (s_PackageInfo == null)
    25.                {
    26.                    s_PackageInfo = PackageManager.PackageInfo.FindForAssembly(typeof(LocalizationSettings).Assembly);
    27.                }
    28.                return s_PackageInfo;
    29.            }
    30.        }
    31.  
    32.        /// <summary>
    33.        /// Updates the Xcode project file with localized values using the <see cref="AppInfo"/> from <see cref="LocalizationSettings.Metadata"/>.
    34.        /// </summary>
    35.        /// <param name="projectDirectory">The root project directory to be updated. This is where the iOS player was built to.</param>
    36.        /// <param name="appInfo"></param>
    37.        public static void AddLocalizationToXcodeProject(string projectDirectory)
    38.        {
    39.            var appInfo = LocalizationSettings.Metadata.GetMetadata<AppInfo>();
    40.            if (appInfo == null)
    41.                return;
    42.            AddLocalizationToXcodeProject(projectDirectory, appInfo);
    43.        }
    44.  
    45.        /// <summary>
    46.        /// Updates the Xcode project file with localized values using <see cref="AppInfo"/>.
    47.        /// </summary>
    48.        /// <param name="projectDirectory">The root project directory to be updated. This is where the iOS player was built to.</param>
    49.        /// <param name="appInfo">Contains the localized values for the App.</param>
    50.        public static void AddLocalizationToXcodeProject(string projectDirectory, AppInfo appInfo)
    51.        {
    52.            if (appInfo == null)
    53.                throw new ArgumentNullException(nameof(appInfo));
    54.  
    55.            var pbxPath = PBXProject.GetPBXProjectPath(projectDirectory);
    56.            var project = new PBXProject();
    57.            project.ReadFromFile(pbxPath);
    58.            project.ClearKnownRegions(); // Remove the deprecated regions that get added automatically.
    59.  
    60.            var plistDocument = new PlistDocument();
    61.            var plistPath = Path.Combine(projectDirectory, "Info.plist");
    62.            plistDocument.ReadFromFile(plistPath);
    63.  
    64.            // Default language
    65.            // How iOS Determines the Language For Your App - https://developer.apple.com/library/archive/qa/qa1828/_index.html
    66.            var developmentRegion = string.IsNullOrEmpty(LocalizationSettings.Instance.m_ProjectLocaleIdentifier.Code) ? LocalizationEditorSettings.GetLocales() ? [0]?.Identifier : LocalizationSettings.Instance.m_ProjectLocaleIdentifier;
    67.            if (developmentRegion.HasValue)
    68.                project.SetDevelopmentRegion(developmentRegion.Value.Code);
    69.            plistDocument.root.SetString("CFBundleDevelopmentRegion", "$(DEVELOPMENT_LANGUAGE)");
    70.  
    71.            // Inclusion of this key improves performance associated with displaying localized application names.
    72.            plistDocument.root.SetBoolean("LSHasLocalizedDisplayName", true);
    73.  
    74.            var bundleLanguages = plistDocument.root.CreateArray("CFBundleLocalizations");
    75.            foreach (var locale in LocalizationEditorSettings.GetLocales())
    76.            {
    77.                var code = locale.Identifier.Code.Replace("-", "_");
    78.                project.AddKnownRegion(code);
    79.                bundleLanguages.AddString(code);
    80.  
    81.                var localeDir = code + ".lproj";
    82.                var dir = Path.Combine(projectDirectory, localeDir);
    83.                Directory.CreateDirectory(dir);
    84.  
    85.                var filePath = Path.Combine(dir, k_InfoFile);
    86.                var relativePath = Path.Combine(localeDir, k_InfoFile);
    87.  
    88.                GenerateLocalizedInfoPlistFile(locale, appInfo, plistDocument, filePath);
    89.                project.AddLocaleVariantFile(k_InfoFile, code, relativePath);
    90.            }
    91.  
    92.            // Defaults
    93.            var projectLocale = LocalizationSettings.ProjectLocale;
    94.            if (projectLocale != null)
    95.            {
    96.                WriteDefaultLocalizedValue("CFBundleName", projectLocale, appInfo.ShortName, plistDocument);
    97.                WriteDefaultLocalizedValue("CFBundleDisplayName", projectLocale, appInfo.DisplayName, plistDocument);
    98.                WriteDefaultLocalizedValue("NSCameraUsageDescription", projectLocale, appInfo.CameraUsageDescription, plistDocument);
    99.                WriteDefaultLocalizedValue("NSMicrophoneUsageDescription", projectLocale, appInfo.MicrophoneUsageDescription, plistDocument);
    100.                WriteDefaultLocalizedValue("NSLocationWhenInUseUsageDescription", projectLocale, appInfo.LocationUsageDescription, plistDocument);
    101.                WriteDefaultLocalizedValue("NSUserTrackingUsageDescription", projectLocale, appInfo.UserTrackingUsageDescription, plistDocument);
    102.            }
    103.            else
    104.            {
    105.                Debug.LogWarning("Project Locale was not configured. Can not set default IOS localized values. Configure the project locale through the Localization Settings.");
    106.            }
    107.  
    108.            plistDocument.WriteToFile(plistPath);
    109.            project.WriteToFile(pbxPath);
    110.        }
    111.  
    112.        static void GenerateLocalizedInfoPlistFile(Locale locale, AppInfo appInfo, PlistDocument plistDocument, string filePath)
    113.        {
    114.            using (var stream = new StreamWriter(filePath, false, Encoding.UTF8))
    115.            {
    116.                stream.Write(
    117.                    "/*\n" +
    118.                    $"\t{k_InfoFile}\n" +
    119.                    $"\tThis file was auto-generated by {LocalizationPackageInfo.name}\n" +
    120.                    $"\tVersion {LocalizationPackageInfo.version}\n" +
    121.                    $"\tChanges to this file may cause incorrect behavior and will be lost if the project is rebuilt.\n" +
    122.                    $"*/\n\n");
    123.  
    124.                WriteLocalizedValue("CFBundleName", stream, locale, appInfo.ShortName, plistDocument);
    125.                WriteLocalizedValue("CFBundleDisplayName", stream, locale, appInfo.DisplayName, plistDocument);
    126.                WriteLocalizedValue("NSCameraUsageDescription", stream, locale, appInfo.CameraUsageDescription, plistDocument);
    127.                WriteLocalizedValue("NSMicrophoneUsageDescription", stream, locale, appInfo.MicrophoneUsageDescription, plistDocument);
    128.                WriteLocalizedValue("NSLocationWhenInUseUsageDescription", stream, locale, appInfo.LocationUsageDescription, plistDocument);
    129.                WriteLocalizedValue("NSUserTrackingUsageDescription", stream, locale, appInfo.UserTrackingUsageDescription, plistDocument);
    130.            }
    131.        }
    132.  
    133.        static void WriteLocalizedValue(string valueName, StreamWriter stream, Locale locale, LocalizedString localizedString, PlistDocument plistDocument)
    134.        {
    135.            if (localizedString.IsEmpty)
    136.                return;
    137.  
    138.            var tableCollection = LocalizationEditorSettings.GetStringTableCollection(localizedString.TableReference);
    139.            var table = tableCollection?.GetTable(locale.Identifier) as StringTable;
    140.            var entry = table?.GetEntryFromReference(localizedString.TableEntryReference);
    141.  
    142.            if (entry == null || string.IsNullOrWhiteSpace(entry.LocalizedValue))
    143.            {
    144.                // Use fallback?
    145.                var fallBack = FallbackLocaleHelper.GetLocaleFallback(locale);
    146.                if (fallBack != null)
    147.                {
    148.                    WriteLocalizedValue(valueName, stream, fallBack, localizedString, plistDocument);
    149.                    return;
    150.                }
    151.  
    152.                Debug.LogWarning($"{valueName}: Could not find a localized value for {locale} from {localizedString}");
    153.                return;
    154.            }
    155.  
    156.            Debug.Assert(!entry.IsSmart, $"Localized App Values ({valueName}) do not support Smart Strings - {localizedString}");
    157.            stream.WriteLine($"\"{valueName}\" = \"{entry.LocalizedValue}\";");
    158.        }
    159.  
    160.        static void WriteDefaultLocalizedValue(string valueName, Locale locale, LocalizedString localizedString, PlistDocument plistDocument)
    161.        {
    162.            if (localizedString.IsEmpty)
    163.                return;
    164.  
    165.            var tableCollection = LocalizationEditorSettings.GetStringTableCollection(localizedString.TableReference);
    166.            var table = tableCollection?.GetTable(locale.Identifier) as StringTable;
    167.            var entry = table?.GetEntryFromReference(localizedString.TableEntryReference);
    168.            plistDocument.root.SetString(valueName, entry?.LocalizedValue);
    169.        }
    170.    }
    171. }
    172. #endif
     
    elaine_unity694 likes this.
  7. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    114
    Hi, I'm having a very similar issue with xcode 14.2 and Unity 2020.3.47f1. All of the identity settings are gone. When I try to archive and send to iTunes, I get errors "Signing for {package name} requires a development team", because the dev team was gone as well. Has anyone managed to fix that?
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    Try updating to 1.4.3 which includes the fix for empty ios field names.
    You may need to manually edit the manifest.json file in the Packages folder if its not visible in the package manager.
     
  9. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    114
    thanks for your reply @karl_jones , I've updated Xcode to 14.3 but am facing the same issue. nothing changed as far as I'm concerned. What do you mean by updating from manifest? The issues are related to facebook SDK and all the other SDKs that don't get signed (quite a few of them)
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    I thought you were having the same issue as this thread. If it's a signing issue then it doesn't sound related to localization. You will need to sign your app with a valid iOS developer license
    https://docs.unity3d.com/Manual/iphone-GettingStarted.html
     
  11. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    114
    Maybe this is not the right thread. I also found this one https://forum.unity.com/threads/identity-lost-on-xcode-14-2.1376223/#post-8942706 This is the issue I'm having. It cannot be signed not because I don't have a valid certificate but because the Signing Team ID field is empty when exporting to XCode