How to fix too many arguments to function error?

I want to iOS remote build from windows10, however I’m bothered with this error when package project.
Please Help me I cant’t code c++

UATHelper: パッケージング (iOS):     In file included from C:\UE4Source\UnrealEngine-4.22\Engine\Intermediate\Build\IOS\UE4\Development\Core\Module.Core.1_of_10.cpp:2:
UATHelper: パッケージング (iOS):     C:\UE4Source\UnrealEngine-4.22\Engine\Source\Runtime\Core\Private\Apple\AppleLLM.cpp:33:36: error: too many arguments to function call, expected 0, have 3
UATHelper: パッケージング (iOS):             id Result = AllocWithZoneOriginal(Obj, Sel, Zone);
UATHelper: パッケージング (iOS):                         ~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~
UATHelper: パッケージング (iOS):     C:\UE4Source\UnrealEngine-4.22\Engine\Source\Runtime\Core\Private\Apple\AppleLLM.cpp:49:18: error: too many arguments to function call, expected 0, have 2
UATHelper: パッケージング (iOS):             DeallocOriginal(Obj, Sel);
UATHelper: パッケージング (iOS):             ~~~~~~~~~~~~~~~ ^~~~~~~~
PackagingResults: Error: too many arguments to function call, expected 0, have 3
PackagingResults: Error: too many arguments to function call, expected 0, have 2
UATHelper: パッケージング (iOS):     2 errors generated.
UATHelper: パッケージング (iOS):   [Remote] Downloading C:\UE4Source\UnrealEngine-4.22\Engine\Programs\AutomationTool\Saved\Logs\UBT-UE4Game-IOS-Development_Remote.txt
UATHelper: パッケージング (iOS):   Total execution time: 19.45 seconds
UATHelper: パッケージング (iOS): Took 19.5063835s to run UnrealBuildTool.exe, ExitCode=7
UATHelper: パッケージング (iOS): ERROR: UnrealBuildTool failed. See log for more details. (C:\UE4Source\UnrealEngine-4.22\Engine\Programs\AutomationTool\Saved\Logs\UBT-UE4Game-IOS-Development.txt)
UATHelper: パッケージング (iOS):        (see C:\UE4Source\UnrealEngine-4.22\Engine\Programs\AutomationTool\Saved\Logs\Log.txt for full exception trace)
PackagingResults: Error: UnrealBuildTool failed. See log for more details. (C:\UE4Source\UnrealEngine-4.22\Engine\Programs\AutomationTool\Saved\Logs\UBT-UE4Game-IOS-Development.txt)
UATHelper: パッケージング (iOS): AutomationTool exiting with ExitCode=7 (7)
UATHelper: パッケージング (iOS): BUILD FAILED
PackagingResults: Error: Unknown Error

from here, AppleLLM.cpp Code

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

#include "Apple/AppleLLM.h"

#if ENABLE_LOW_LEVEL_MEM_TRACKER

#include <objc/runtime.h>
#if PLATFORM_MAC
#include "rd_route.h"
#endif

struct FLLMTagInfoApple
{
	const TCHAR* Name;
	FName StatName;				// shows in the LLMFULL stat group
	FName SummaryStatName;		// shows in the LLM summary stat group
};

DECLARE_LLM_MEMORY_STAT(TEXT("Objective-C"), STAT_ObjectiveCLLM, STATGROUP_LLMPlatform);

// *** order must match ELLMTagApple enum ***
const FLLMTagInfoApple ELLMTagNamesApple[] =
{
	// csv name						// stat name								// summary stat name						// enum value
	{ TEXT("Objective-C"),				GET_STATFNAME(STAT_ObjectiveCLLM),		NAME_None },									// ELLMTagApple::ObjectiveC
};

static IMP AllocWithZoneOriginal = nullptr;
static IMP DeallocOriginal = nullptr;

static id AllocWithZoneInterposer(id Obj, SEL Sel, struct _NSZone * Zone)
{
	id Result = AllocWithZoneOriginal(Obj, Sel, Zone);
	
	if (Result)
	{
		LLM(FLowLevelMemTracker::Get().OnLowLevelAlloc(ELLMTracker::Default, Result, class_getInstanceSize([Result class]), (ELLMTag)ELLMTagApple::ObjectiveC, ELLMAllocType::System));
	}
	
	return Result;
}

static void DeallocInterposer(id Obj, SEL Sel)
{
	if (Obj)
	{
		LLM(FLowLevelMemTracker::Get().OnLowLevelFree(ELLMTracker::Default, Obj, ELLMAllocType::System));
	}
	DeallocOriginal(Obj, Sel);
}

static id (*NSAllocateObjectPtr)(Class aClass, NSUInteger extraBytes, NSZone *zone) = nullptr;

id NSAllocateObjectPtrInterposer(Class aClass, NSUInteger extraBytes, NSZone *zone)
{
	id Result = NSAllocateObjectPtr(aClass, extraBytes, zone);
	if (Result)
	{
		LLM(FLowLevelMemTracker::Get().OnLowLevelAlloc(ELLMTracker::Default, Result, class_getInstanceSize([Result class]), (ELLMTag)ELLMTagApple::ObjectiveC, ELLMAllocType::System));
	}
	
	return Result;
}

static id (*_os_object_alloc_realizedPtr)(Class aClass, size_t size) = nullptr;
id _os_object_alloc_realizedInterposer(Class aClass, size_t size)
{
	id Result = _os_object_alloc_realizedPtr(aClass, size);
	if (Result)
	{
		LLM(FLowLevelMemTracker::Get().OnLowLevelAlloc(ELLMTracker::Default, Result, class_getInstanceSize([Result class]), (ELLMTag)ELLMTagApple::ObjectiveC, ELLMAllocType::System));
	}
	
	return Result;
}

static void (*NSDeallocateObjectPtr)(id Obj) = nullptr;

void NSDeallocateObjectInterposer(id Obj)
{
	if (Obj)
	{
		LLM(FLowLevelMemTracker::Get().OnLowLevelFree(ELLMTracker::Default, Obj, ELLMAllocType::System));
	}
	NSDeallocateObjectPtr(Obj);
}

/*
 * Register Apple tags with LLM and setup the NSObject +alloc:, -dealloc interposers, some Objective-C allocations will already have been made, but there's not much I can do about that.
 */
void AppleLLM::Initialise()
{
	int32 TagCount = sizeof(ELLMTagApple) / sizeof(FLLMTagInfoApple);

	for (int32 Index = 0; Index < TagCount; ++Index)
	{
		int32 Tag = (int32)ELLMTag::PlatformTagStart + Index;
		const FLLMTagInfoApple& TagInfo = ELLMTagNamesApple[Index];

		FLowLevelMemTracker::Get().RegisterPlatformTag(Tag, TagInfo.Name, TagInfo.StatName, TagInfo.SummaryStatName);
	}
	
#if PLATFORM_MAC
	// Use rd_route to hook NSAllocateObject/_os_object_alloc_realized/NSDeallocateObject that are used in custom allocators within Apple's libraries
	// Necessary to avoid crashes because we otherwise can't track these allocations.
	// For this to work on iOS we would need to get TPS approval for libevil which performs the same function and handle the function-name -> ptr search available separately.
	int err = rd_route_byname("NSAllocateObject", nullptr, (void*)&NSAllocateObjectPtrInterposer, (void**)&NSAllocateObjectPtr);
	check(err == 0);
	
	err = rd_route_byname("_os_object_alloc_realized", nullptr, (void*)&_os_object_alloc_realizedInterposer, (void**)&_os_object_alloc_realizedPtr);
	check(err == 0);
	
	err = rd_route_byname("NSDeallocateObject", nullptr, (void*)&NSDeallocateObjectInterposer, (void**)&NSDeallocateObjectPtr);
	check(err == 0);
	
	Method AllocZone = class_getClassMethod([NSObject class], @selector(allocWithZone:));
	Method Dealloc = class_getInstanceMethod([NSObject class], @selector(dealloc));
	
	AllocWithZoneOriginal = method_getImplementation(AllocZone);
	DeallocOriginal = method_getImplementation(Dealloc);
	
	check(AllocWithZoneOriginal);
	check(DeallocOriginal);
	
	method_setImplementation(AllocZone, (IMP)&AllocWithZoneInterposer);
	method_setImplementation(Dealloc, (IMP)&DeallocInterposer);
#endif
}

#endif		// #if ENABLE_LOW_LEVEL_MEM_TRACKER

I fixed this problem.

https://github.com/EpicGames/UnrealEngine/commit/d7c706ae85a47d12b8c78928791009086309b531#diff-520e6c4db7d7b3b93834e7c93660318b

A little bit different source code, but almost same.

I am having this exact same error while trying to build for iOS. The github link is broken.

Has anyone else experienced this?

AllocWithZoneOriginal(Obj, Sel, Zone);
Too many arguments.

The file in question:
Engine\Source\Runtime\Core\Private\Apple\AppleLLM.cpp

Any help would be appreciated.

I searched for it now, but couldn’t find the source code with the same thing.
I recommend that you upgrade the UE4 version or bring the project to your Mac and then build it on your Mac’s UE4.

I’m not using UE4 anymore so I don’t have any more information.

Good Luck.

The github link still works if you are added to the ue4 project. I attached screenshots so you can see the changes, and the added code is copyable below.

	/** Publicly movable */
	FLocTextConflicts(FLocTextConflicts&&) = default;
	FLocTextConflicts& operator=(FLocTextConflicts&&) = default;

typedef id (*AllocWithZoneIMP)(id Obj, SEL Sel, struct _NSZone* Zone);
typedef id (*DeallocIMP)(id Obj, SEL Sel);
static AllocWithZoneIMP AllocWithZoneOriginal = nullptr;
static DeallocIMP DeallocOriginal = nullptr;

	AllocWithZoneOriginal = (AllocWithZoneIMP)method_getImplementation(AllocZone);
	DeallocOriginal = (DeallocIMP)method_getImplementation(Dealloc);

	check(AllocWithZoneOriginal);
	check(DeallocOriginal);

Thank you, !

My Epic and GitHub accounts don’t seem to be connected correctly, causing the 404 on all of the UE4 repo, but that is exactly what I needed!