C++ projects

Some additional consideration for C++ projects when using Bridge.

Additional notes for C++ projects

Server targets

When a project is deployed using Bridge CLI, a Server Target is created behind the scenes. This is required to facilitate multiplayer play. If in your project's codebase you reference any plugin (engine or third party) that has the Server target listed in its TargetDenyList, the build will fail. This TargetDenyList information is found in the plugin's .uplugin file. A BinkMedia plugin is an example of such a non-server plugin:

To avoid this error, please follow these requirements:

  1. Encapsulate the code that references the non-server plugins inside the#if !UE_SERVER precompile directives

    #if !UE_SERVER
    #include "../Plugins/Media/BinkMedia/Source/BinkMediaPlayer/Public/BinkMediaPlayer.h" // this is an example of a non-server plugin
    #endif
    
    void AActorReferencingNonServerPlugin::RunLogic(const UObject* binkPlayer)
    {
    #if !UE_SERVER
        if (!binkPlayer || !Cast<UBinkMediaPlayer>(binkPlayer)) // reference the specific plugin symbol inside the !UE_SERVER clause
        {
            return false;
        }
    
        const FString& filePath = Cast<UBinkMediaPlayer>(binkPlayer)->URL;
    #endif
    }
    
  2. In your project's .build.cs file, only add the module references if Target is not Server.

    public class VideoTest : ModuleRules  
    {  
    	public VideoTest(ReadOnlyTargetRules Target) : base(Target)  
    	{  
    		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
    		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });
    
    		if (Target.Type != TargetType.Server)
        {
    			PrivateDependencyModuleNames.AddRange(new string[] { "BinkMediaPlayer" });
        }
    	}
    }