How can I implement a new UFactory as a plugin?

I had this same sort of problem, and I solved it by adding an include for UnrealEd.h in the cpp file