Unable to instantiate UnrealEd module for non-editor targets

I see this when packaging the project for windows 64 bit.
**Error: **Unable to instantiate UnrealEd module for non-editor targets

I understand this means I must be using something that should be editor use only, but I’m not sure where it’s coming from. I only have two Function Libraries which could be causing this. So I’ll list the headers in those that I’m using:

  1. I have a file that I’m using to clear cookies.


#include "Runtime\WebBrowser\Public\IWebBrowserSingleton.h"
#include "Runtime\WebBrowser\Public\WebBrowserModule.h"
#include "Runtime\WebBrowser\Public\IWebBrowserCookieManager.h"


  1. This file is used to decrypt some string from my server


#include "SecurityBlueprintFunctionLibrary.h"
#include <string>

FString USecurityBlueprintFunctionLibrary::DecryptMessage(const FString Message)
{
std::string s = "some salt";
std::string p = "some password";
std::string modMess = std::string(TCHAR_TO_UTF8(*Message));

// I've removed my actual decryption for obvious reasons.

return FString(modMess.c_str());

}


Maybe it could be some plugin? Here’s my plugins:


"Plugins": 
{
"Name": "SoundVisualizations",
"Enabled": true
},
{
"Name": "OculusVR",
"Enabled": false,
"SupportedTargetPlatforms": 
"Win32",
"Win64",
"Android"
]
},
{
"Name": "SteamVR",
"Enabled": false,
"SupportedTargetPlatforms": 
"Win32",
"Win64",
"Linux",
"Mac"
]
},
{
"Name": "VaRest",
"Enabled": true,
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/e47be161e7a24e928560290abd5dcc4f"
},
{
"Name": "WebBrowserWidget",
"Enabled": true
}
]

And my AdditionalDependencies only includes “Engine”

1 Like

Okay I read through the logs and I see this:


UnrealBuildTool.Main: ERROR: Unable to instantiate module 'UnrealEd': Unable to instantiate UnrealEd module for non-editor targets.
UnrealBuildTool.Main: (referenced via Target -> **NativizedAssets**.Build.cs -> Blutility.Build.cs -> MainFrame.Build.cs)

NativizedAssets.Build.cs That’s where it’s happening.

This plugin is enabled by default: Enabling plugin ‘NativizedAssets’ (referenced via default plugins)

And I have my Blueprint Nativization Method set to inclusive. Probably this?

2 Likes

That was it, disabling nativization fixed the problem. Though I would rather use nativization… seems it has some bugs.

5 Likes

UnrealEd contains dependencies for automated testing, hence cannot be packaged. This can be resolved by introducing conditions while including any module that has dependencies on UnrealEd. and keeping the code that is utilizing UnrealEd within #if WITH_EDITOR

5 Likes

Is there another way that doesn’t rely on using #if s?
i work better without them.
like for example setting the target in the .uproject or the plugins definition or build.cs?

I found this video. It helped! https://youtu.be/9O_YansI-Fs

Edit: Here is a newer version: https://youtu.be/HhW4O2XhdZQ

3 Likes

Video is not available :confused: or rather (after some search), it’s locked behind a Youtube membership paywall. Can we please post the solution here instead?

1 Like

Here you go: https://youtu.be/HhW4O2XhdZQ

I think you can add the following code to the project.build.cs:
if (Target.bBuildEditor)
{
PrivateDependencyModuleNames.AddRange(new string { “UnrealEd” });
}

这表示只有在编辑器下才会有UnrealEd模块

3 Likes

Not entirely related but but it might be relevant to people stumbling upon this thread from search. If using classes derived from Blutility, UnrealEd or other modules that aren’t allowed to be packaged, there is a workaround one can use by making a fake imposter module. Unfortunately it requires to use #if and #endif, but it works. Example: Subclasses of UEditorUtilityWidget don’t package due to missing the base class.

#include "EditorUtilityWidget.h" // Initially problematic in packaged build, but keep as-is, it will be fixed.

UCLASS()
class GAME_API UMyEditorUtilityWidget : public UEditorUtilityWidget
{
    GENERATED_BODY()
public:
#if WITH_EDITOR
// UFUNCTIONS...
#endif
#if WITH_EDITORONLY_DATA
// UPROPERTIES...
#endif

^ doesn’t package yet!

This is because of typical use in Game.Build.cs that filters out the necessary headers:

        if (Target.bBuildEditor)
        {
            PrivateDependencyModuleNames.AddRange(new string[] { "UnrealEd" });
            PrivateDependencyModuleNames.AddRange(new string[] { "Blutility" });
        }

But, one can add an ‘imposter’ module as such to the Game.Build.cs:

        if (!Target.bBuildEditor)
        {
            PrivateDependencyModuleNames.AddRange(new string[]
            {
                "FakeUtil" // Uses fake placeholder classes used by private dependencies, to please UHT / GENERATED_BODY. Mostly empty.
            });
        }

The idea is to create an imposter module that fills in empty classes for the packaged build. In the project’s Source folder, next to Game.Target.cs, add a folder FakeUtil.
FakeUtil/FakeUtil.Build.cs:

using UnrealBuildTool;

public class FakeUtil : ModuleRules
{
    public FakeUtil(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
        
        PublicDependencyModuleNames.AddRange(new string[] {
            "Core",
            "CoreUObject",
            "Engine"
        });
    }
}

FakeUtil/Private/FakeUtilModule.cpp:

#include "Modules/ModuleManager.h"

class FFakeUtilModule : public IModuleInterface
{
};

IMPLEMENT_MODULE(FFakeUtilModule, FakeUtil)

Then, create the imposter class based on the header include name in the problematic classes. Place it as such:
FakeUtil/Public/EditorUtilityWidget.h: (or any other included editor-type class that is in use by the project)

#pragma once

#include "CoreMinimal.h"
#include "EditorUtilityWidget.generated.h"

UCLASS()
class FAKEUTIL_API UEditorUtilityWidget : public USceneComponent // imposter
{
    GENERATED_BODY()
};

It’s probably not a good workflow to end up here in the first place, but for anyone who stumbled into using ‘editor-only c++ classes’ this is a workaround. Ideally it would be as easy as UCLASS(EditorOnly) or GENERATED_EDITOR_BODY(), or similar.