
Localization関係を設定している時の問題ですが、前回記載した通り、
Unity2022.3.62f1
Localization1.5.7
というバージョン状態の時に、BuildSettings→PlayeerSettings→LocalizationのMetaData内にList追加しようとすると、本来、iOSAppInfoと表示されるところ?AppleAppInfoという表示になっていた。
この問題は、Localizationのバージョンを1.5.7から1.5.2にすることでとりあえず解決しました。
しかしながら、App Store Connectへアップロードしようとした時に以下のように発生したエラーは解決しませんでした。
No architectures in the binary. Lipo failed to detect any architectures in the bundle executable. (ID: 1bab56be-b29c-459f-a82e-af75c7a06cf4)
いろいろとやっている中で、アプリ名のLocalize設定はEditor内でスクリプト作成してできることが分かりそちらのやり方に変更しました。
そのやり方は以下のようになります。
Unity で何度も Xcode を吐き直す場合は、PostProcessBuild のスクリプトを入れておくと便利ということです。
Unity が出力した Xcode プロジェクトに自動で ja.lproj/InfoPlist.strings と en.lproj/InfoPlist.strings を作り、プロジェクトに追加してくれます。
以下を Unity プロジェクトの Assets/Editor/ フォルダに PostProcessCreateLocalizedInfoPlist.cs という名前で保存してください。
#if UNITY_IOS
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
public static class PostProcessCreateLocalizedInfoPlist
{
// ここに表示名を言語ごとに書いてください
static readonly (string locale, string displayName)[] Locales = new (string,string)[]
{
("ja", "アプリ名(日本語)"),
("en", "App Name (English)"),
// 必要なら追加: ("fr", "Nom en Français"),
};
[PostProcessBuild(999)]
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
{
if (target != BuildTarget.iOS) return;
// PBXProject を読み込み
string projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
// Unity のメインターゲット GUID を取得(Unity のバージョンによりメソッドが異なることに注意)
string targetGuid = proj.GetUnityMainTargetGuid(); // Unity 2019+ 推奨API
// string targetGuid = proj.TargetGuidByName("Unity-iPhone"); // 互換用
// プロジェクトルートに locale.lproj フォルダを作り InfoPlist.strings を追加
foreach (var (locale, displayName) in Locales)
{
string lprojFolderName = locale + ".lproj";
string lprojFullPath = Path.Combine(pathToBuiltProject, lprojFolderName);
if (!Directory.Exists(lprojFullPath))
Directory.CreateDirectory(lprojFullPath);
string fileNameInProj = Path.Combine(lprojFolderName, "InfoPlist.strings");
string fileFullPath = Path.Combine(lprojFullPath, "InfoPlist.strings");
// ファイル内容(エスケープに注意)
File.WriteAllText(fileFullPath, $"\"CFBundleDisplayName\" = \"{displayName}\";");
// Xcode プロジェクトに追加(既に存在する場合は重複追加を避ける)
string fileGuid = proj.AddFile(fileNameInProj, fileNameInProj);
proj.AddFileToBuild(targetGuid, fileGuid);
}
// 保存
File.WriteAllText(projPath, proj.WriteToString());
Debug.Log("[PostProcessCreateLocalizedInfoPlist] Added localized InfoPlist.strings to Xcode project.");
}
}
#endif
使い方:
-
Locales配列にロケールコードと表示名を入れてください(日本語ja、英語enなど)。 -
Unity → Build iOS を行うと、Xcode プロジェクトに自動で
ja.lproj/InfoPlist.strings等が追加され、Xcode 上で再設定する必要はほぼありません。 -
注意:Unity の出力を毎回上書きする場合は、スクリプトが自動で追加します(Xcode 側での手作業を不要にします)。
これにて進めていくことで、エラーは解消し、無事、App Store Connectへアップロードできました。