Add existing file to JUCE project

From windows, I create a GUI (say) project A in one Projucer window and a blank project B in another. Both targeting VS2015.

A contains 2 files in its /sources/ whereas the B contains none.

Let's say I want to copy these 2 files across.

I can find A/sources/ in Explorer and drag drop onto Projucer's File tab.

Alternatively I can copy them from A/sources/ to B/sources/ then right click on sources in Projucer's File tab and add them.

However whichever I do, if I 'launch in IDE', they don't show up. And consequently build fails as it cannot find main.

Is this some bug?

π

EDIT: I kind of solved this by creating new files using ProJucer and copying the contents of the original files into them. Ultra-lame!

Just checking as it wasn't clear: you need to hit "Save Project and Open in IDE..." are you doing that?

Yep, if the files appear in the Projucer's "File" tab, then this should definitely work after you save the Project.

Let me know if there's still a problem.

Hi, any update to this issue? I’m having the exact same problem, with the exact same not great solution that the OP came up with in their edit. The problem arises even if I use Projucer’s “Add existing files…” option in the + button

Create a git submodule in project B and refer to them in the projucer. That’s what I’m doing and works without an itch.

2024 and I still can’t get this to work. Files that are dragged into the projucer, or added using “add existing files” from the + button appear in the projucer’s “File” tab are not seen by xcode as being part of the project. And when I “reveal in finder” they are not in the same folder as the original projucer files. I’m not sure how to create a submodule.

What did work for me was to choose “add new cpp file” or “add new header file” and then copy and paste my code into the new files. Not fun if you have to do multiple files.

And what’s really funny about this is that when I do the thing that doesn’t work, the files are perfectly aligned with the projucer created files like Main.cpp. When I do the thing that does work the files the files are indented less and don’t look like the are in the same folder as Main.cpp. Really weird



@maaaaaaark it might help if you post some screenshots to describe what you mean, like this.



If you are going to have files in folders other than /Source, you need to specifically include their paths:

I thought I did add test.h to Source. I would think anyone looking at my screenshots would also think so, but apparently adding an existing file just adds a reference to the original location of the file, which is not what I want.

Is there a way to quickly add a few files, not references to files in other folders, to a juce project? Drag and drop doesn’t work, it does the same as “add existing file”. There doesn’t seem to be any way to do it besides creating new empty files one at a time and copying and pasting the code I want in to the new empty files. That’s kind of time consuming and annoying, but doable

Well, it looks like test.h was added to a folder called /test.

I think you might want to ensure that test.h is inside the folder “Source” by checking the native finder, rather than the Projucer.

The Projucer’s file explorer accounts for mappings, not folder specific hierarchies. This means that you can have Source/test in the Projucer while simultaneously seeing Source/Test/test in the Finder.

General rule of thumb, create files outside of Projucer, drag them in. If you’re using the ‘+’ button to add files, ensure you’re adding the file to the source directory in the File Chooser that pops up.

Actually test.h was added to the projucer project from a folder called test. My screenshot depciting the folder test shows where the file came from just before I “added” it to the project. The other screenshots show a file called test.h which appears to be in the same folder with the other source files, which it isn’t of course. Thanks for your help in understanding how the projucer adds files to projects