Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/Platform/Mac/UEDeployMac.cs
Josh Adams 7a9968a030 - Fix for bad bundle id for editor builds in installed build projects, related to the plist changes needed for Xcode14
#jira UE-169934
#preflight 6372664db6636838286afa32

[CL 23119760 by Josh Adams in ue5-main branch]
2022-11-14 11:49:56 -05:00

80 lines
2.8 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using Ionic.Zip;
using EpicGames.Core;
using Microsoft.Extensions.Logging;
namespace UnrealBuildTool
{
class UEDeployMac : UEBuildDeploy
{
public UEDeployMac(ILogger InLogger)
: base(InLogger)
{
}
public override bool PrepTargetForDeployment(TargetReceipt Receipt)
{
Logger.LogInformation("Deploying now!");
return base.PrepTargetForDeployment(Receipt);
}
public static bool GeneratePList(string ProjectDirectory, bool bIsUnrealGame, string GameName, string ProjectName, string InEngineDir, string ExeName)
{
string IntermediateDirectory = (bIsUnrealGame ? InEngineDir : ProjectDirectory) + "/Intermediate/Mac";
string DestPListFile = IntermediateDirectory + "/" + ExeName + "-Info.plist";
string SrcPListFile = (bIsUnrealGame ? (InEngineDir + "Source/Programs/") : (ProjectDirectory + "/Source/")) + GameName + "/Resources/Mac/Info.plist";
if (!File.Exists(SrcPListFile))
{
SrcPListFile = InEngineDir + "/Source/Runtime/Launch/Resources/Mac/Info.plist";
}
string PListData;
if (File.Exists(SrcPListFile))
{
PListData = File.ReadAllText(SrcPListFile);
}
else
{
return false;
}
// bundle identifier
// plist replacements
DirectoryReference? DirRef = bIsUnrealGame ? (!string.IsNullOrEmpty(UnrealBuildTool.GetRemoteIniPath()) ? new DirectoryReference(UnrealBuildTool.GetRemoteIniPath()!) : null) : new DirectoryReference(ProjectDirectory);
ConfigHierarchy Ini = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirRef, UnrealTargetPlatform.IOS);
string BundleIdentifier;
Ini.GetString("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "BundleIdentifier", out BundleIdentifier);
string BundleVersion = MacToolChain.LoadEngineDisplayVersion();
// duplicating some logic in MacToolchain for the BundleID
string[] ExeNameParts = ExeName.Split('-');
bool bBuildingEditor = ExeNameParts[0].EndsWith("Editor");
string FinalBundleID = bBuildingEditor ? $"com.epicgames.{ExeNameParts[0]}" : BundleIdentifier.Replace("[PROJECT_NAME]", ProjectName);
FinalBundleID = FinalBundleID.Replace("_", "");
PListData = PListData.Replace("${EXECUTABLE_NAME}", ExeName).
Replace("${APP_NAME}", FinalBundleID).
Replace("${ICON_NAME}", GameName).
Replace("${MACOSX_DEPLOYMENT_TARGET}", MacToolChain.Settings.MinMacOSVersion).
Replace("${BUNDLE_VERSION}", BundleVersion);
if (!Directory.Exists(IntermediateDirectory))
{
Directory.CreateDirectory(IntermediateDirectory);
}
File.WriteAllText(DestPListFile, PListData);
return true;
}
}
}