[FIXED} OpenGL changes broke ObjC helpers

JUCE has helpers to interact with native macOS/iOS APIs, like juce::createNSURLFromFile, which are available when one #define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 before including JUCE’s header. Note that I’m not sure that this is the correct usage, and to make this work for me I also had to #include <AVFoundation/AVFoundation.h> and <objc/message.h> before JUCE.

After merging the latest OpenGL related changes, I now get the error “gltypes.h included before juce_gl.h”. I don’t get this error if not including AVFoundation first, but if I don’t, then including JuceHeader fails for “Use of undeclared identifier NSRange:frowning:

Update: My problem was specifically from including AVFoundation before JUCE. For JUCE itself Foundation would suffice and if I need its APIs I can move AVFoundation’s include to after.

The following snippet seems to build, perhaps this would work for you:

#import <Foundation/Foundation.h>
#import <objc/message.h>
#include <juce_opengl/juce_opengl.h>
1 Like

Over here it gives the same “ gltypes.h included before juce_gl.h ” error as before.

Using Xcode 12.5, on macOS 11.2.3 with cmake based build (with its Xcode exporter),

Is there somewhere else that gltypes.h might be included? Perhaps you could try temporarily modifying gltypes.h to add an #error near the beginning. This should force the compiler to emit the chain of includes that eventually includes the gltypes header.

Oh, now I noticed that your example used Foundation while mine used AVFoundation.

If I indeed use your example and include AVFoudation after JuceHeader then it does seem to work, thanks!

1 Like