Plugin packaging error (WITH_EDITOR)

I’m trying to build Unreal with a plugin on Linux.

The plugin has a class that calls UStaticMesh::SetMaterial.

But UStaticMesh::SetMaterial is only defined if the preprocessor variable WITH_EDITOR is defined.

I don’t know if there is a “correct” way to define that. From my reading it sounds like it is intended to only be set by the UE build tools, but I’m not sure.

Does anyone have experience with this sort of thing? Can you build a package when WITH_EDITOR is defined to be true?

Is there a better way to set the material on a static mesh that doesn’t require the editor?