Linking error in editor only

My C++ code can be compiled in XCode successfully. And my UE project can be built successfully for release.

But if I click the button in editor for live-coding, it starts to compile and then failed with following error. It seems it cannot find the symbol of FMetalContext::GetCommandQueue()

CompilerResultsLog: [4/6] Compile [Apple] SceneVideoCapture.cpp
CompilerResultsLog: [5/6] Link [Apple] UnrealEditor-MacDemo-5615.dylib
CompilerResultsLog: Undefined symbols for architecture arm64:
CompilerResultsLog:   "FMetalContext::GetCommandQueue()", referenced from:
CompilerResultsLog:       ASceneVideoCapture::BeginPlay() in SceneVideoCapture.cpp.o
CompilerResultsLog:   "FMetalCommandQueue::CommitCommandBuffer(mtlpp::CommandBuffer&)", referenced from:
CompilerResultsLog:       ASceneVideoCapture::BeginPlay() in SceneVideoCapture.cpp.o
CompilerResultsLog: ld: symbol(s) not found for architecture arm64
CompilerResultsLog: clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have added MetalRHI in my Build.cs

		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
	
        PrivateDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Slate", "RenderCore", "RHI", "RHICore", "Projects"  });


        
        if (Target.Platform == UnrealTargetPlatform.Mac)
        {

            PrivateDependencyModuleNames.AddRange(new string[] { "MetalRHI" });
            PublicWeakFrameworks.Add("Metal");
            AddEngineThirdPartyPrivateStaticDependencies(Target, "MTLPP");
            
            string srcPath = Path.Combine( ModuleDirectory, "lib", "libipc.dylib");
            string binariesDir = Path.Combine(GetUProjectPath(), "Binaries", Target.Platform.ToString());
            File.Copy(srcPath, Path.Combine(binariesDir, "libipc.dylib"), true);
            RuntimeDependencies.Add("$(BinaryOutputDir)/libipc.dylib", srcPath);
            
            string libFile = Path.Combine( ModuleDirectory, "lib", "libfrida-gum.a");
            PublicAdditionalLibraries.Add(libFile);
            PublicIncludePaths.AddRange(new string[] { Path.Combine( ModuleDirectory, "lib") });
        }
        else 
        {
            
            string srcPath = Path.Combine( ModuleDirectory, "lib", "ipc.dll");
            string binariesDir = Path.Combine(GetUProjectPath(), "Binaries", Target.Platform.ToString());
            File.Copy(srcPath, Path.Combine(binariesDir, "ipc.dll"), true);
            RuntimeDependencies.Add("$(BinaryOutputDir)/ipc.dll", srcPath);
        }

Why it only failed to link in editor model?

Thanks in advance