Skip to content

Commit 267fb63

Browse files
Fix CA::MetalLayer undeclared in C++ TUs via forward declaration
<QuartzCore/CAMetalLayer.h> only defines an Objective-C @interface, not the C++ CA::MetalLayer class from Metal-cpp. BabylonNative.cpp is compiled as a pure C++ translation unit, so including that header does not make the CA:: namespace visible. Replace the include with a C++ forward declaration: namespace CA { class MetalLayer; } This is sufficient for the pointer type alias in the header. The full definition is provided by the Metal-cpp headers that BabylonNative itself brings in when the implementation files are compiled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8721561 commit 267fb63

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/@babylonjs/react-native/shared/BabylonNative.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
#if defined(__APPLE__)
66
#include <MetalKit/MTKView.h>
7-
#include <QuartzCore/CAMetalLayer.h>
7+
// Forward-declare CA::MetalLayer so BabylonNative.h is usable from pure C++
8+
// translation units. The ObjC header <QuartzCore/CAMetalLayer.h> only defines
9+
// the @interface, not the C++ CA:: namespace class from Metal-cpp.
10+
namespace CA { class MetalLayer; }
811
#elif defined(ANDROID)
912
#include <android/native_window.h>
1013
#elif WINAPI_FAMILY == WINAPI_FAMILY_APP

0 commit comments

Comments
 (0)