JUCE user module dependencies

I want to split one of my user modules into two separate ones. However, some classes in moduleB (GUI widgets) are dependent of classes in moduleA (lookAndFeel) and the classes in moduleB are not seeing the classes in moduleA.

here are my module’s header files

moduleA.h

BEGIN_JUCE_MODULE_DECLARATION

 ID:            moduleA
 vendor:        xxx
 version:       1.0
 name:          MODULE_A
 description:   Custom Look and Feel
 dependencies:  juce_gui_basics, juce_gui_extra, juce_events
 license:       MIT

 END_JUCE_MODULE_DECLARATION

 ==============================================================================
 */

#pragma once
#define SB_LOOK_AN_FEEL_H_INCLUDED


#include <juce_audio_basics/juce_audio_basics.h>
#include <juce_gui_basics/juce_gui_basics.h>
#include <juce_gui_extra/juce_gui_extra.h>
#include <juce_events/juce_events.h>

#include "FontRoboto.h"

#include "SBLookAndFeel.h"

moduleB.

BEGIN_JUCE_MODULE_DECLARATION

 ID:            moduleB
 vendor:        xxx
 version:       1.0
 name:          MODULE_B
 description:   Custom GUI widgets
 dependencies:  juce_gui_basics, juce_gui_extra, juce_events, sb_look_and_feel
 license:       MIT

 END_JUCE_MODULE_DECLARATION

 ==============================================================================
 */

#pragma once
#define SB_WIDGETS_H_INCLUDED


#include <juce_audio_basics/juce_audio_basics.h>
#include <juce_gui_basics/juce_gui_basics.h>
#include <juce_gui_extra/juce_gui_extra.h>
#include <juce_events/juce_events.h>

#include <sb_look_and_feel/sb_look_and_feel.h>

#include "SBColourSelector.h"
#include "SBPreferencesPanel.h"
#include "SBRoundColourButton.h"


Now if a class in moduleB tries to access a class in moduleA (from SBLookAndFeel.h), I got an “unknown type name” error in Xcode.

Both modules are loaded in my JUCE project and from there I can instantiate objects of both modules without problems.

Any advice on that?

thanks
Stefan

In moduleB.h add:

dependencies: moduleA

//Later in the header file:
#include <moduleA/moduleA.h>

No need to explicitly specify Module A’s dependencies or includes to module B beyond that.

Oh sorry, that was a typo. I changed the names in moduleA and moduleB for simplicity’s sake and forgot to rename the dependencies and #include in moduleB.h as well. I did I it actually exactly as you posted above.

In that case, that should work. If you’re using the Projucer you’d need to re-save the project and in CMake you’d need to call the generator again.

Also, check to see that you don’t have includes for JuceHeader.h or something like that anywhere in your modules, as this would break things.

:man_facepalming: That was the issue.

Thanks eyalamir!