ModuleManager: Module 'OnlineSubsystemNull' not found

I had set up a blueprint project where I was successfully using OnlineSubsystemNull. After adding an empty c++ class to the project I cannot create sessions anymore, and in the logs I see the following error:

LogModuleManager:Warning: ModuleManager: Module 'OnlineSubsystemNull' not found - its StaticallyLinkedModuleInitializers function is null.

I have modified DefaultEngine.ini to include:

[OnlineSubsystem]
DefaultPlatformService=Null

And PROJECTNAME.Build.cs as follow:

// Fill out your copyright notice in the Description page of Project Settings.

using UnrealBuildTool;

public class Test2 : ModuleRules
{
	public Test2(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "OnlineSubsystemNull"});

		PrivateDependencyModuleNames.AddRange(new string[] {  });

		PrivateDependencyModuleNames.Add("OnlineSubsystem");
		DynamicallyLoadedModuleNames.Add("OnlineSubsystemNull");

	}
}

The module gets compiled:

MainFrameActions: Packaging (Mac): mono: [43/179] Compile Module.OnlineSubsystemNull.cpp

But apparently not linked to the executable. Am I missing something?

Is this related to this bug: “Adding C++ code to Android project breaks Google Play integration”?

It looks like it could be related to the bug I mentioned on the related forum thread (UE-13075). You can try using the “Refresh Xcode project” from the Unreal Editor’s File menu before re-launching or re-packaging your project.

Refreshing Xcode project didn’t seem to fix the issue, probably I was not configuring the build.cs file correctly. This worked for me:

	PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem"});
	PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "OnlineSubsystemNull" });
	DynamicallyLoadedModuleNames.Add("OnlineSubsystemNull");