UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IOSCommandLineHelper.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Misc/CommandLine.h"
7
8#define IOS_MAX_PATH 1024
9#define CMD_LINE_MAX 16384
10
12
14{
15 public:
22 {
23 // the saved commandline may be in the format ?opt?opt -opt -opt, so we need to insert it
24 // after the first token on the commandline unless the first token starts with a -, in which
25 // case use it at the start of the command line
26 if (CommandLine[0] == '-' || CommandLine[0] == 0)
27 {
28 // handle the easy - case, just use the saved command line part as the start, in case it
29 // started with a ?
32 }
33 else
34 {
35 // otherwise, we need to get the first token from the command line and insert after
36 TCHAR* Space = FCString::Strchr(CommandLine, ' ');
37 if (Space == NULL)
38 {
39 // if there is only one token (no spaces), just append us after it
41 }
42 else
43 {
44 // save off what's after the space (include the space for pasting later)
45 FString AfterSpace(Space);
46 // copy the save part where the space was
48 // now put back the 2nd and so on token
50 }
51 }
52 }
53
54 static bool TryReadCommandLineFile(const FString& CommandLineFilePath)
55 {
56 bool bHasFile = false;
57
58 // initialize the commandline
59 // read in the command line text file (coming from UnrealFrontend) if it exists
62 {
63 FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Checking for command line in %s... FOUND!") LINE_TERMINATOR, *CommandLineFilePath);
64 char CommandLine[CMD_LINE_MAX] = {0};
66 if (DataExists)
67 {
68 // chop off trailing spaces
70 {
72 }
73
75 }
77 bHasFile = true;
78 }
79 else
80 {
81 FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Checking for command line in %s... NOT FOUND!") LINE_TERMINATOR, *CommandLineFilePath);
82 }
83
84 return bHasFile;
85 }
86
88 {
89 // initialize the commandline
91
92 // command line text file included in the bundle
93 FString BundleCommandLineFilePath = FString([[NSBundle mainBundle] bundlePath]) + TEXT("/uecommandline.txt");
94
95 // command line text file pushed to the documents folder
97
98#if UE_BUILD_SHIPPING
100#else
102#endif
103
106 {
108 }
109
110 FString ReplacementCL, AppendCL;
111 bool bHasReplacementCL = FPlatformMisc::GetStoredValue(TEXT(""), TEXT("IOSCommandLine"), TEXT("ReplacementCL"), ReplacementCL);
112 bool bHasAppendCL = FPlatformMisc::GetStoredValue(TEXT(""), TEXT("IOSCommandLine"), TEXT("AppendCL"), AppendCL);
113
115 {
117 }
118
119 if (bHasAppendCL)
120 {
123 }
124
126 {
129 }
130
131 // now merge the GSavedCommandLine with the rest
134
136 }
137};
138
#define NULL
Definition oodle2base.h:134
#define LINE_TERMINATOR
Definition Platform.h:902
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define CMD_LINE_MAX
Definition IOSCommandLineHelper.h:9
APPLICATIONCORE_API FString GSavedCommandLine
Definition LaunchIOS.cpp:610
#define UTF8_TO_TCHAR(str)
Definition StringConv.h:1022
#define TCHAR_TO_UTF8(str)
Definition StringConv.h:1021
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
Definition IOSCommandLineHelper.h:14
static void MergeCommandlineWithSaved(TCHAR CommandLine[16384])
Definition IOSCommandLineHelper.h:21
static void InitCommandArgs(FString AdditionalCommandArgs)
Definition IOSCommandLineHelper.h:87
static bool TryReadCommandLineFile(const FString &CommandLineFilePath)
Definition IOSCommandLineHelper.h:54
static CORE_API bool GetStoredValue(const FString &InStoreId, const FString &InSectionName, const FString &InKeyName, FString &OutValue)
Definition AndroidPlatformMisc.cpp:866
static CORE_API void Append(const TCHAR *AppendString)
Definition CommandLine.cpp:138
static CORE_API bool Set(const TCHAR *NewCommandLine)
Definition CommandLine.cpp:85
static CORE_API const TCHAR * Get()
Definition CommandLine.cpp:61
static CORE_API void VARARGS LowLevelOutputDebugStringf(const TCHAR *Format,...)
Definition GenericPlatformMisc.cpp:940
static CharType * StrncatTruncateDest(CharType *Dest, int32 DestSize, const CharType *Src)
Definition CString.h:281
static CharType * Strncpy(CharType *Dest, const CharType *Src, SIZE_T MaxLen)
Definition CString.h:991
static UE_FORCEINLINE_HINT const CharType * Strchr(const CharType *String, CharType c)
Definition CString.h:1078
static bool IsWhitespace(CharType Char)
Definition Char.h:282