Ejemplo n.º 1
0
		private void AppendLegacyTargetBuildConfiguration(StringBuilder Content, XcodeBuildConfig Config, string ConfigGuid)
		{
			bool bMacOnly = true;
			if (Config.ProjectTarget.TargetRules != null && XcodeProjectFileGenerator.ProjectFilePlatform.HasFlag(XcodeProjectFileGenerator.XcodeProjectFilePlatform.iOS))
			{
				var SupportedPlatforms = new List<UnrealTargetPlatform>();
				Config.ProjectTarget.TargetRules.GetSupportedPlatforms(ref SupportedPlatforms);
				if (SupportedPlatforms.Contains(UnrealTargetPlatform.IOS))
				{
					bMacOnly = false;
				}
			}

			Content.Append("\t\t" + ConfigGuid + " /* \"" + Config.DisplayName + "\" */ = {" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tisa = XCBuildConfiguration;" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tbuildSettings = {" + ProjectFileGenerator.NewLine);
			if (bMacOnly)
			{
				Content.Append("\t\t\t\tVALID_ARCHS = \"x86_64\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tSUPPORTED_PLATFORMS = \"macosx\";" + ProjectFileGenerator.NewLine);
			}
			else
			{
				string ValidArchs = "x86_64";
				string SupportedPlatforms = "macosx";
				if (UnrealBuildTool.IsValidPlatform(UnrealTargetPlatform.IOS))
				{
					ValidArchs += " arm64 armv7 armv7s";
					SupportedPlatforms += " iphoneos";
				}
				if (UnrealBuildTool.IsValidPlatform(UnrealTargetPlatform.TVOS))
				{
					if (ValidArchs == "x86_64")
					{
						ValidArchs += " arm64 armv7 armv7s";
					}
					SupportedPlatforms += " appletvos";
				}
				Content.Append("\t\t\t\tVALID_ARCHS = \"" + ValidArchs + "\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tSUPPORTED_PLATFORMS = \"" + SupportedPlatforms + "\";" + ProjectFileGenerator.NewLine);
			}
			Content.Append("\t\t\t\tUE_BUILD_TARGET_NAME = \"" + Config.BuildTarget + "\";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t\tUE_BUILD_TARGET_CONFIG = \"" + Config.BuildConfig + "\";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t};" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tname = \"" + Config.DisplayName + "\";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t};" + ProjectFileGenerator.NewLine);
		}
Ejemplo n.º 2
0
		private void AppendNativeTargetBuildConfiguration(StringBuilder Content, XcodeBuildConfig Config, string ConfigGuid, bool bIsAGame, string GameProjectPath)
		{
			bool bMacOnly = true;
			if (Config.ProjectTarget.TargetRules != null && XcodeProjectFileGenerator.ProjectFilePlatform.HasFlag(XcodeProjectFileGenerator.XcodeProjectFilePlatform.iOS))
			{
				var SupportedPlatforms = new List<UnrealTargetPlatform>();
				Config.ProjectTarget.TargetRules.GetSupportedPlatforms(ref SupportedPlatforms);
				if (SupportedPlatforms.Contains(UnrealTargetPlatform.IOS))
				{
					bMacOnly = false;
				}
			}

			Content.Append("\t\t" + ConfigGuid + " /* \"" + Config.DisplayName + "\" */ = {" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tisa = XCBuildConfiguration;" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tbuildSettings = {" + ProjectFileGenerator.NewLine);

			MacPlatform MacBuildPlat = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Mac) as MacPlatform;
			MacBuildPlat.SetUpProjectEnvironment(UnrealTargetPlatform.Mac);

            MacToolChain Toolchain = UEToolChain.GetPlatformToolChain(CPPTargetPlatform.Mac) as MacToolChain;
            string UE4Dir = Toolchain.ConvertPath(Path.GetFullPath(Directory.GetCurrentDirectory() + "../../.."));
			string MacExecutableFileName = Path.GetFileName(Config.MacExecutablePath);

			if (bMacOnly)
			{
				Content.Append("\t\t\t\tVALID_ARCHS = \"x86_64\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tSUPPORTED_PLATFORMS = \"macosx\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tPRODUCT_NAME = \"" + MacExecutableFileName + "\";" + ProjectFileGenerator.NewLine);
                Content.Append("\t\t\t\tCONFIGURATION_BUILD_DIR = \"" + Toolchain.ConvertPath(Path.GetDirectoryName(Config.MacExecutablePath)) + "\";" + ProjectFileGenerator.NewLine);
			}
			else
			{
				IOSPlatform IOSBuildPlat = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.IOS) as IOSPlatform;
				IOSBuildPlat.SetUpProjectEnvironment(UnrealTargetPlatform.IOS);

				Content.Append("\t\t\t\tVALID_ARCHS = \"x86_64 arm64 armv7 armv7s\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tSUPPORTED_PLATFORMS = \"macosx iphoneos\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\t\"PRODUCT_NAME[sdk=macosx*]\" = \"" + MacExecutableFileName + "\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\t\"PRODUCT_NAME[sdk=iphoneos*]\" = \"" + Config.BuildTarget + "\";" + ProjectFileGenerator.NewLine); // @todo: change to Path.GetFileName(Config.IOSExecutablePath) when we stop using payload
				Content.Append("\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = " + IOSBuildPlat.GetRunTimeVersion() + ";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tTARGETED_DEVICE_FAMILY = \"" + IOSBuildPlat.GetRunTimeDevices() + "\";" + ProjectFileGenerator.NewLine);
                Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=macosx*]\" = \"" + Toolchain.ConvertPath(Path.GetDirectoryName(Config.MacExecutablePath)) + "\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\t\"SDKROOT[arch=x86_64]\" = macosx;" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\t\"SDKROOT[arch=arm*]\" = iphoneos;" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tINFOPLIST_OUTPUT_FORMAT = xml;" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\t\"PROVISIONING_PROFILE[sdk=iphoneos*]\" = \"\";" + ProjectFileGenerator.NewLine);

				bool bIsUE4Game = Config.BuildTarget.Equals("UE4Game", StringComparison.InvariantCultureIgnoreCase);
				bool bIsUE4Client = Config.BuildTarget.Equals("UE4Client", StringComparison.InvariantCultureIgnoreCase);

                string GamePath = string.IsNullOrEmpty(GameProjectPath) ? null : Toolchain.ConvertPath(Path.GetDirectoryName(GameProjectPath));

				string IOSInfoPlistPath = null;
				string MacInfoPlistPath = null;
				if (bIsUE4Game)
				{
					IOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/IOS/" + Config.BuildTarget + "-Info.plist";
					MacInfoPlistPath = UE4Dir + "/Engine/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=iphoneos*]\" = \"" + UE4Dir + "/Engine/Binaries/IOS/Payload\";" + ProjectFileGenerator.NewLine);
				}
				else if (bIsUE4Client)
				{
					IOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/IOS/UE4Game-Info.plist";
					MacInfoPlistPath = UE4Dir + "/Engine/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=iphoneos*]\" = \"" + UE4Dir + "/Engine/Binaries/IOS/Payload\";" + ProjectFileGenerator.NewLine);
				}
				else if (bIsAGame)
				{
					IOSInfoPlistPath = GamePath + "/Intermediate/IOS/" + Config.BuildTarget + "-Info.plist";
					MacInfoPlistPath = GamePath + "/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=iphoneos*]\" = \"" + GamePath + "/Binaries/IOS/Payload\";" + ProjectFileGenerator.NewLine);
				}
				else
				{
					if (string.IsNullOrEmpty(GamePath))
					{
						IOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/IOS/" + Config.BuildTarget + "-Info.plist";
						MacInfoPlistPath = UE4Dir + "/Engine/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					}
					else
					{
						IOSInfoPlistPath = GamePath + "/Intermediate/IOS/" + Config.BuildTarget + "-Info.plist";
						MacInfoPlistPath = GamePath + "/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					}
					Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=iphoneos*]\" = \"" + UE4Dir + "/Engine/Binaries/IOS/Payload\";" + ProjectFileGenerator.NewLine);
				}

				if (XcodeProjectFileGenerator.bGeneratingRunIOSProject)
				{
					Content.Append("\t\t\t\tINFOPLIST_FILE = \"" + IOSInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
				}
				else
				{
					Content.Append("\t\t\t\t\"INFOPLIST_FILE[sdk=macosx*]\" = \"" + MacInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
					Content.Append("\t\t\t\t\"INFOPLIST_FILE[sdk=iphoneos*]\" = \"" + IOSInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
				}

				// Prepare a temp Info.plist file so Xcode has some basic info about the target immediately after opening the project.
				// This is needed for the target to pass the settings validation before code signing. UBT will overwrite this plist file later, with proper contents.
				if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac)
				{
					bool bCreateMacInfoPlist = !File.Exists(MacInfoPlistPath);
					bool bCreateIOSInfoPlist = !File.Exists(IOSInfoPlistPath);
					if (bCreateMacInfoPlist || bCreateIOSInfoPlist)
					{
						string ProjectPath = GamePath;
						string EngineDir = UE4Dir + "/Engine";
						string GameName = Config.BuildTarget;
						if (string.IsNullOrEmpty(ProjectPath))
						{
							ProjectPath = EngineDir;
						}
						if (bIsUE4Game)
						{
							ProjectPath = EngineDir;
							GameName = "UE4Game";
						}

						if (bCreateMacInfoPlist)
						{
							Directory.CreateDirectory(Path.GetDirectoryName(MacInfoPlistPath));
							Mac.UEDeployMac.GeneratePList(ProjectPath, bIsUE4Game, GameName, Config.BuildTarget, EngineDir, MacExecutableFileName);
						}
						if (bCreateIOSInfoPlist)
						{
							Directory.CreateDirectory(Path.GetDirectoryName(IOSInfoPlistPath));
							IOS.UEDeployIOS.GeneratePList(ProjectPath, bIsUE4Game, GameName, Config.BuildTarget, EngineDir, ProjectPath + "/Binaries/IOS/Payload");
						}
					}
				}
			}
			Content.Append("\t\t\t\tMACOSX_DEPLOYMENT_TARGET = " + MacToolChain.MacOSVersion + ";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t\tSDKROOT = macosx;" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t\tGCC_PRECOMPILE_PREFIX_HEADER = YES;" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t\tGCC_PREFIX_HEADER = \"" + UE4Dir + "/Engine/Source/Editor/UnrealEd/Public/UnrealEd.h\";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t};" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tname = \"" + Config.DisplayName + "\";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t};" + ProjectFileGenerator.NewLine);
		}
Ejemplo n.º 3
0
		private void AppendNativeTargetBuildConfiguration(StringBuilder Content, XcodeBuildConfig Config, string ConfigGuid, bool bIsAGame, FileReference ProjectFile)
		{
			bool bMacOnly = true;
			if (Config.ProjectTarget.TargetRules != null && XcodeProjectFileGenerator.ProjectFilePlatform.HasFlag(XcodeProjectFileGenerator.XcodeProjectFilePlatform.iOS))
			{
				var SupportedPlatforms = new List<UnrealTargetPlatform>();
				Config.ProjectTarget.TargetRules.GetSupportedPlatforms(ref SupportedPlatforms);
				if (SupportedPlatforms.Contains(UnrealTargetPlatform.IOS))
				{
					bMacOnly = false;
				}
			}

			Content.Append("\t\t" + ConfigGuid + " /* \"" + Config.DisplayName + "\" */ = {" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tisa = XCBuildConfiguration;" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tbuildSettings = {" + ProjectFileGenerator.NewLine);

            if (UnrealBuildTool.IsValidPlatform(UnrealTargetPlatform.Mac))
            {
                MacPlatform MacBuildPlat = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Mac) as MacPlatform;
                MacPlatformContext PlatformContextMac = (MacPlatformContext)MacBuildPlat.CreateContext(ProjectFile);
                PlatformContextMac.SetUpProjectEnvironment(Config.BuildConfig);
            }
            else if (UnrealBuildTool.IsValidPlatform(UnrealTargetPlatform.IOS))
            {
                IOSPlatform IOSBuildPlat = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.IOS) as IOSPlatform;
                IOSPlatformContext PlatformContextIOS = (IOSPlatformContext)IOSBuildPlat.CreateContext(ProjectFile);
                PlatformContextIOS.SetUpProjectEnvironment(Config.BuildConfig);
            }
            else
            {
                throw new BuildException("No valid build platform found when trying to generate an Xcode project file.");
            }

            string UE4Dir = ConvertPath(Path.GetFullPath(Directory.GetCurrentDirectory() + "../../.."));
			string MacExecutableDir = ConvertPath(Config.MacExecutablePath.Directory.FullName);
			string MacExecutableFileName = Config.MacExecutablePath.GetFileName();

			if (bMacOnly)
			{
				Content.Append("\t\t\t\tVALID_ARCHS = \"x86_64\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tSUPPORTED_PLATFORMS = \"macosx\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tPRODUCT_NAME = \"" + MacExecutableFileName + "\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tCONFIGURATION_BUILD_DIR = \"" + MacExecutableDir + "\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;" + ProjectFileGenerator.NewLine);
			}
			else
			{
				string IOSRunTimeVersion = null;
				string IOSRunTimeDevices = null;
				string TVOSRunTimeVersion = null;
				string TVOSRunTimeDevices = null;
				string ValidArchs = "x86_64";
				string SupportedPlatforms = "macosx";

                string UUID_IOS = "";
                string UUID_TVOS = "";
                string TEAM_IOS = "";
                string TEAM_TVOS = "";
                string IOS_CERT = "iPhone Developer";
                string TVOS_CERT = "iPhone Developer";
                if (UnrealBuildTool.IsValidPlatform(UnrealTargetPlatform.IOS))
                {
                    IOSPlatform IOSBuildPlat = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.IOS) as IOSPlatform;
					IOSPlatformContext PlatformContextIOS = (IOSPlatformContext)IOSBuildPlat.CreateContext(ProjectFile);
					PlatformContextIOS.SetUpProjectEnvironment(Config.BuildConfig);
					IOSRunTimeVersion = PlatformContextIOS.GetRunTimeVersion();
					IOSRunTimeDevices = PlatformContextIOS.GetRunTimeDevices();
					ValidArchs += " arm64 armv7 armv7s";
					SupportedPlatforms += " iphoneos";
                    UUID_IOS = PlatformContextIOS.MobileProvisionUUID;
                    TEAM_IOS = PlatformContextIOS.TeamUUID;
                    IOS_CERT = PlatformContextIOS.SigningCertificate;
                }

                if (UnrealBuildTool.IsValidPlatform(UnrealTargetPlatform.TVOS))
				{
					TVOSPlatform TVOSBuildPlat = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.TVOS) as TVOSPlatform;
					TVOSPlatformContext PlatformContextTVOS = (TVOSPlatformContext)TVOSBuildPlat.CreateContext(ProjectFile);
					PlatformContextTVOS.SetUpProjectEnvironment(Config.BuildConfig);
					TVOSRunTimeVersion = PlatformContextTVOS.GetRunTimeVersion();
					TVOSRunTimeDevices = PlatformContextTVOS.GetRunTimeDevices();
					if (ValidArchs == "x86_64")
					{
						ValidArchs += " arm64 armv7 armv7s";
					}
					SupportedPlatforms += " appletvos";
                    UUID_TVOS = PlatformContextTVOS.MobileProvisionUUID;
                    TEAM_TVOS = PlatformContextTVOS.TeamUUID;
                    TVOS_CERT = PlatformContextTVOS.SigningCertificate;
                }

                Content.Append("\t\t\t\tVALID_ARCHS = \"" + ValidArchs + "\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tSUPPORTED_PLATFORMS = \"" + SupportedPlatforms + "\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\t\"PRODUCT_NAME[sdk=macosx*]\" = \"" + MacExecutableFileName + "\";" + ProjectFileGenerator.NewLine);
				if (IOSRunTimeVersion != null)
				{
					Content.Append("\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = " + IOSRunTimeVersion + ";" + ProjectFileGenerator.NewLine);
					Content.Append("\t\t\t\t\"PRODUCT_NAME[sdk=iphoneos*]\" = \"" + Config.BuildTarget + "\";" + ProjectFileGenerator.NewLine); // @todo: change to Path.GetFileName(Config.IOSExecutablePath) when we stop using payload
					Content.Append("\t\t\t\t\"TARGETED_DEVICE_FAMILY[sdk=iphoneos*]\" = \"" + IOSRunTimeDevices + "\";" + ProjectFileGenerator.NewLine);
                    Content.Append("\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"" + IOS_CERT + "\";" + ProjectFileGenerator.NewLine);
                    Content.Append("\t\t\t\t\"SDKROOT[sdk=iphoneos]\" = iphoneos;" + ProjectFileGenerator.NewLine);
                    Content.Append("\t\t\t\t\"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]\" = \"" + UUID_IOS + "\";" + ProjectFileGenerator.NewLine);
                    Content.Append("\t\t\t\t\"DEVELOPMENT_TEAM[sdk=iphoneos*]\" = \"" + TEAM_IOS + "\";" + ProjectFileGenerator.NewLine);
                }
                if (TVOSRunTimeVersion != null)
				{
					Content.Append("\t\t\t\tTVOS_DEPLOYMENT_TARGET = " + TVOSRunTimeVersion + ";" + ProjectFileGenerator.NewLine);
					Content.Append("\t\t\t\t\"PRODUCT_NAME[sdk=appletvos*]\" = \"" + Config.BuildTarget + "\";" + ProjectFileGenerator.NewLine); // @todo: change to Path.GetFileName(Config.TVOSExecutablePath) when we stop using payload
					Content.Append("\t\t\t\t\"TARGETED_DEVICE_FAMILY[sdk=appletvos*]\" = \"" + TVOSRunTimeDevices + "\";" + ProjectFileGenerator.NewLine);
                    Content.Append("\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=appletvos*]\" = \"" + TVOS_CERT + "\";" + ProjectFileGenerator.NewLine);
                    Content.Append("\t\t\t\t\"SDKROOT[sdk=appletvos]\" = appletvos;" + ProjectFileGenerator.NewLine);
                    Content.Append("\t\t\t\t\"PROVISIONING_PROFILE_SPECIFIER[sdk=appletvos*]\" = \"" + UUID_TVOS + "\";" + ProjectFileGenerator.NewLine);
                    Content.Append("\t\t\t\t\"DEVELOPMENT_TEAM[sdk=appletvos*]\" = \"" + TEAM_TVOS + "\";" + ProjectFileGenerator.NewLine);
                }
                Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=macosx*]\" = \"" + MacExecutableDir + "\";" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\t\"SDKROOT[sdk=macosx]\" = macosx;" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tINFOPLIST_OUTPUT_FORMAT = xml;" + ProjectFileGenerator.NewLine);
				Content.Append("\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;" + ProjectFileGenerator.NewLine);

				bool bIsUE4Game = Config.BuildTarget.Equals("UE4Game", StringComparison.InvariantCultureIgnoreCase);
				bool bIsUE4Client = Config.BuildTarget.Equals("UE4Client", StringComparison.InvariantCultureIgnoreCase);

				DirectoryReference GameDir = ProjectFile != null ? ProjectFile.Directory : null;
				string GamePath = GameDir != null ? ConvertPath(GameDir.FullName) : null;

				string IOSInfoPlistPath = null;
				string TVOSInfoPlistPath = null;
				string MacInfoPlistPath = null;
				if (bIsUE4Game)
				{
					IOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/IOS/" + Config.BuildTarget + "-Info.plist";
					TVOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/TVOS/" + Config.BuildTarget + "-Info.plist";
					MacInfoPlistPath = UE4Dir + "/Engine/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					if (IOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=iphoneos*]\" = \"" + UE4Dir + "/Engine/Binaries/IOS/Payload\";" + ProjectFileGenerator.NewLine);
					}
					if (TVOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=appletvos*]\" = \"" + UE4Dir + "/Engine/Binaries/TVOS/Payload\";" + ProjectFileGenerator.NewLine);
					}
				}
				else if (bIsUE4Client)
				{
					IOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/IOS/UE4Game-Info.plist";
					TVOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/TVOS/UE4Game-Info.plist";
					MacInfoPlistPath = UE4Dir + "/Engine/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					if (IOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=iphoneos*]\" = \"" + UE4Dir + "/Engine/Binaries/IOS/Payload\";" + ProjectFileGenerator.NewLine);
					}
					if (TVOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=appletvos*]\" = \"" + UE4Dir + "/Engine/Binaries/TVOS/Payload\";" + ProjectFileGenerator.NewLine);
					}
				}
				else if (bIsAGame)
				{
					IOSInfoPlistPath = GamePath + "/Intermediate/IOS/" + Config.BuildTarget + "-Info.plist";
					TVOSInfoPlistPath = GamePath + "/Intermediate/TVOS/" + Config.BuildTarget + "-Info.plist";
					MacInfoPlistPath = GamePath + "/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					if (IOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=iphoneos*]\" = \"" + GamePath + "/Binaries/IOS/Payload\";" + ProjectFileGenerator.NewLine);
					}
					if (TVOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=appletvos*]\" = \"" + GamePath + "/Binaries/TVOS/Payload\";" + ProjectFileGenerator.NewLine);
					}
				}
				else
				{
					if (GamePath == null)
					{
						IOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/IOS/" + Config.BuildTarget + "-Info.plist";
						TVOSInfoPlistPath = UE4Dir + "/Engine/Intermediate/TVOS/" + Config.BuildTarget + "-Info.plist";
						MacInfoPlistPath = UE4Dir + "/Engine/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					}
					else
					{
						IOSInfoPlistPath = GamePath + "/Intermediate/IOS/" + Config.BuildTarget + "-Info.plist";
						TVOSInfoPlistPath = GamePath + "/Intermediate/TVOS/" + Config.BuildTarget + "-Info.plist";
						MacInfoPlistPath = GamePath + "/Intermediate/Mac/" + MacExecutableFileName + "-Info.plist";
					}
					if (IOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=iphoneos*]\" = \"" + UE4Dir + "/Engine/Binaries/IOS/Payload\";" + ProjectFileGenerator.NewLine);
					}
					if (TVOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"CONFIGURATION_BUILD_DIR[sdk=appletvos*]\" = \"" + UE4Dir + "/Engine/Binaries/TVOS/Payload\";" + ProjectFileGenerator.NewLine);
					}
				}

				if (XcodeProjectFileGenerator.bGeneratingRunIOSProject)
				{
					Content.Append("\t\t\t\tINFOPLIST_FILE = \"" + IOSInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
				}
				else if (XcodeProjectFileGenerator.bGeneratingRunTVOSProject)
				{
					Content.Append("\t\t\t\tINFOPLIST_FILE = \"" + TVOSInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
				}
				else
				{
					Content.Append("\t\t\t\t\"INFOPLIST_FILE[sdk=macosx*]\" = \"" + MacInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
					if (IOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"INFOPLIST_FILE[sdk=iphoneos*]\" = \"" + IOSInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
					}
					if (TVOSRunTimeVersion != null)
					{
						Content.Append("\t\t\t\t\"INFOPLIST_FILE[sdk=appletvos*]\" = \"" + TVOSInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
					}
				}

				// Prepare a temp Info.plist file so Xcode has some basic info about the target immediately after opening the project.
				// This is needed for the target to pass the settings validation before code signing. UBT will overwrite this plist file later, with proper contents.
				if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac)
				{
					bool bCreateMacInfoPlist = !File.Exists(MacInfoPlistPath);
					bool bCreateIOSInfoPlist = !File.Exists(IOSInfoPlistPath) && IOSRunTimeVersion != null;
					bool bCreateTVOSInfoPlist = !File.Exists(TVOSInfoPlistPath) && TVOSRunTimeVersion != null;
					if (bCreateMacInfoPlist || bCreateIOSInfoPlist || bCreateTVOSInfoPlist)
					{
						DirectoryReference ProjectPath = GameDir;
						DirectoryReference EngineDir = DirectoryReference.Combine(new DirectoryReference(UE4Dir), "Engine");
						string GameName = Config.BuildTarget;
						if (ProjectPath == null)
						{
							ProjectPath = EngineDir;
						}
						if (bIsUE4Game)
						{
							ProjectPath = EngineDir;
							GameName = "UE4Game";
						}

						if (bCreateMacInfoPlist)
						{
							Directory.CreateDirectory(Path.GetDirectoryName(MacInfoPlistPath));
							UEDeployMac.GeneratePList(ProjectPath.FullName, bIsUE4Game, GameName, Config.BuildTarget, EngineDir.FullName, MacExecutableFileName);
						}
						if (bCreateIOSInfoPlist)
						{
							Directory.CreateDirectory(Path.GetDirectoryName(IOSInfoPlistPath));
							UEDeployIOS.GenerateIOSPList(ProjectPath.FullName, bIsUE4Game, GameName, Config.BuildTarget, EngineDir.FullName, ProjectPath + "/Binaries/IOS/Payload");
						}
						if (bCreateTVOSInfoPlist)
						{
							Directory.CreateDirectory(Path.GetDirectoryName(TVOSInfoPlistPath));
							UEDeployTVOS.GenerateTVOSPList(ProjectPath.FullName, bIsUE4Game, GameName, Config.BuildTarget, EngineDir.FullName, ProjectPath + "/Binaries/TVOS/Payload");
						}
					}
				}
			}
			Content.Append("\t\t\t\tMACOSX_DEPLOYMENT_TARGET = " + MacToolChain.MacOSVersion + ";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t\tSDKROOT = macosx;" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t\tGCC_PRECOMPILE_PREFIX_HEADER = YES;" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t\tGCC_PREFIX_HEADER = \"" + UE4Dir + "/Engine/Source/Editor/UnrealEd/Public/UnrealEd.h\";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\t};" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t\tname = \"" + Config.DisplayName + "\";" + ProjectFileGenerator.NewLine);
			Content.Append("\t\t};" + ProjectFileGenerator.NewLine);
		}
Ejemplo n.º 4
0
    private static void DoBuildIOSInternal(XcodeBuildConfig buildType, iOSSdkVersion sdkVersion)
    {
        Debug.Log("Building iOS...");

        CurrentGroup = BuildTargetGroup.iOS;

        var xrGeneralSettings            = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.iOS);
        var prevCompilerConfiguration    = PlayerSettings.GetIl2CppCompilerConfiguration(BuildTargetGroup.iOS);
        var prevScriptingDefines         = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS);
        var prev_sdkVersion              = PlayerSettings.iOS.sdkVersion;
        var prev_provisioningProfileId   = PlayerSettings.iOS.iOSManualProvisioningProfileID;
        var prev_provisioningProfileType = PlayerSettings.iOS.iOSManualProvisioningProfileType;
        var isDebug       = !(buildType == XcodeBuildConfig.Debug);
        var disabledARKit = false;

        using var revertSettings = new Disposable(() =>
        {
            CurrentGroup = null;

            PlayerSettings.iOS.sdkVersion = prev_sdkVersion;
            PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.iOS, prevCompilerConfiguration);

            if (isDebug || sdkVersion == iOSSdkVersion.SimulatorSDK)
            {
                PlayerSettings.iOS.iOSManualProvisioningProfileID   = prev_provisioningProfileId;
                PlayerSettings.iOS.iOSManualProvisioningProfileType = prev_provisioningProfileType;
            }

            if (!Application.isBatchMode)
            {
                PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, prevScriptingDefines);
            }

            if (disabledARKit)
            {
                XRPackageMetadataStore.AssignLoader(
                    xrGeneralSettings.AssignedSettings,
                    typeof(UnityEngine.XR.ARKit.ARKitLoader).FullName,
                    BuildTargetGroup.iOS);
            }
        });

        var compilerConfiguration = isDebug ? Il2CppCompilerConfiguration.Debug : Il2CppCompilerConfiguration.Master;

        PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.iOS, compilerConfiguration);
        PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, ProcessDefines(prevScriptingDefines, isDebug));
        PlayerSettings.iOS.sdkVersion = sdkVersion;

        if (isDebug || sdkVersion == iOSSdkVersion.SimulatorSDK)
        {
            PlayerSettings.iOS.iOSManualProvisioningProfileID   = String.Empty;
            PlayerSettings.iOS.iOSManualProvisioningProfileType = ProvisioningProfileType.Automatic;
        }

        if (sdkVersion == iOSSdkVersion.SimulatorSDK &&
            xrGeneralSettings.AssignedSettings.activeLoaders.Any(m => m.GetType() == typeof(UnityEngine.XR.ARKit.ARKitLoader)))
        {
            // ARKit is not supported on iOS Simulator - disable it temporairly
            XRPackageMetadataStore.RemoveLoader(
                xrGeneralSettings.AssignedSettings,
                typeof(UnityEngine.XR.ARKit.ARKitLoader).FullName,
                BuildTargetGroup.iOS);
            disabledARKit = true;
        }

        string exportPath = Path.GetFullPath(Path.Combine(ProjectPath, "../../ios/UnityExport"));
        string buildPath  = iosBuildPath;

        if (Directory.Exists(buildPath))
        {
            Directory.Delete(buildPath, true);
        }

        EditorUserBuildSettings.iOSXcodeBuildConfig = buildType;

        try
        {
            var options = (buildType == XcodeBuildConfig.Debug ? BuildOptions.AllowDebugging : BuildOptions.None);
            var report  = BuildPipeline.BuildPlayer(
                GetEnabledScenes(),
                buildPath,
                BuildTarget.iOS,
                options
                );

            if (report.summary.result != BuildResult.Succeeded)
            {
                throw new Exception("Build failed");
            }

            // Clear UnityExport
            DeleteFolderContent(exportPath);

            // Copy build output to UnityExport
            Debug.Log("Copy to UnityExport");
            CopyDirectory(
                buildPath,
                exportPath,
                mergeDirectories: false,
                overwriteFiles: true);
        }
        catch (Exception e)
        {
            Debug.Log("Export failed!");

            if (Application.isBatchMode)
            {
                Debug.LogError(e);
                EditorApplication.Exit(-1);
            }
            else
            {
                throw;
            }
        }
        finally
        {
            Debug.Log("Export completed!");

            if (Application.isBatchMode)
            {
                EditorApplication.Exit(0);
            }
        }
    }