I actually was having the same problem. Note I am using SetupAttachment to attach the components in projectile.cpp. Your solutions also worked. However the same problem occurred again with the radial impulse, so I started debugging. Short solution, delete all derived content. Add this line to your projectile.h:
#include “Components/StaticMeshComponent.h”
rebuild and it should work.
Long answer:
What I found was an error in the code compilation. I removed all the derived folders. Then tried to launch unreal and it couldn’t build the project, which I have found means there is a compile error. I opened the visual studio project, tried building. It complained a ustaticmeshcomponent couldn’t be a uscenecomponent. I tried including “Components/StaticMeshComponent.h” in the projectile.h, and that cleared that up as well as SetupAttachment working properly.
Just thought I’d post this because it was a weird bug, hope it helps someone and when in doubt, delete all derived content and rebuild