Problem adding c++ to perforce project

When I try to add new code to my project running in a perforce workspace, I get the error

“Failed to add class NewClass. Failed to generate project files.”.

I assume this is because of the write only default in perforce but I’m not really sure how to get around it. It does actually create the files though, but I assume it doesn’t link up with UE and isn’t usable.

I also tried asking here but it didn’t help much.

You need a perforce client to do this the ordinary way.
Grab it here:
Perforce 20 User Downloads
you might also check out this:
Visual Studio Plugin

Then connect to your workspace, and check out the file(s) you need.

I just installed the plugin you linked so thanks for that. I already had perforce installed which is why I think I’m having this problem. I guess I’ve solved it. I have to create the files manually and not through UE, and then I have to write both files from scratch, so it kinda sucks.

Well it should work, creating them manually might work but i don’t know if it will course any troubles later…
Also make sure you do not check in the sln, suo or sdf files, because they might get recreated by the UE Build Tool and you do not want to check them out again and again :wink:

You didn’t happen to check in the “Intermediate” or “Saved” folders did you? If you did be sure to take remove them from the depot. Also none of the visual studio related files should be checked in either. (.sln, .sdf, etc)
Also, sometimes files that aren’t even in the depot can sometimes be made read only, so that could be it too, if thats the case you could manually untick the read only option for any files that aren’t under source control. This should probably completely fix your issue.

I did add the “Intermediate” and “Saved” folders to the depot. I’m not really sure they can be removed from the depot without also deleting the local copy. And wouldn’t other people need them if they were working with the code as well?

I’m also pretty sure VS always forces me to have all the VS related files checked out before doing anything, which I have to launch the game from every time for some odd reason… They’re basically always checked out.

I’ve tried to do what you said (forcefully, screwed up my files pretty bad at one point lol) but it didn’t seem to help. I get around it now by manually creating the files. Also, even though the error happens, the files are still generated but not added to the project, so I have to manually add them. Is there any other repercussions for ignoring the warning? Thanks for the suggestions!

Nobody on the team needs “Intermediate” or “Saved” to be shared, its 100% safe to just delete them. This is exactly why its not working for you.

“I’m also pretty sure VS always forces me to have all the VS related files checked out before doing anything”

What VS related files?

Also, is the perforce plugin for visual studio setup correctly?

I deleted the “Intermediate” and “Saved” folders and it didn’t fix anything. Also the VS related files are the .sln .sdf .suo files. When you say they shouldn’t be checked in, do you mean I should always have them checked out or they shouldn’t be in the depot at all?

The plugin is also set up correctly.

I meant that the .sln, sdf, .suo, etc should not be in the depot at all.

Well, I never got the error to go away, but it seems to work fine even with the error. So I’ll mark you’re answer since you were the most helpful. Thanks for everything.