Attaching GLFW (MAC) Cocoa Window to IPlugView (PLEASE HELP)

,

Hi i’m currently trying to use GLFW as my host’s vst editor window but am getting the error:

[GLFWWindow window]: unrecognized selector sent to instance 0x7fe10430a830
2022-12-22 08:11:08.981 MyHost[1593:20791] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GLFWWindow window]: unrecognized selector sent to instance 0x7fe10430a830'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff37903a17 __exceptionPreprocess + 250
        1   libobjc.A.dylib                     0x00007fff70468a9e objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff37982e36 -[NSObject(NSObject) __retain_OA] + 0
        3   CoreFoundation                      0x00007fff37868190 ___forwarding___ + 1427
        4   CoreFoundation                      0x00007fff37867b68 _CF_forwarding_prep_0 + 120
        5   Digitalis                           0x000000010a9dc990 GetPluginFactory + 1922288
        6   Digitalis                           0x000000010a9dbb85 GetPluginFactory + 1918693
        7   Digitalis                           0x000000010a80db6e GetPluginFactory + 26318
        8   MyHost                              0x000000010a624641 _ZN6Plugin4loadERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 2065
        9   MyHost                              0x000000010a624e9d main + 61
        10  libdyld.dylib                       0x00007fff71608cc9 start + 1
        11  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

i guess this leads me to question whether the kPlatformType “NSView” is equivalent to glfwGetCocoaWindow()'s “NSWindow” return value?

heres the snippet of code thats causing errors:

  if (!glfwInit()) {
    std::cout << "Failed to initialise Editor Window" << std::endl;
    return false;
  }

  auto view = controller->createView(Steinberg::Vst::ViewType::kEditor);

  Steinberg::ViewRect dimensions;
  
  view->getSize(&dimensions);

  editorWindow = glfwCreateWindow(dimensions.getWidth(), dimensions.getHeight(), "VST 3 SDK", nullptr, nullptr);
  
  view->attached(glfwGetCocoaWindow(editorWindow), Steinberg::kPlatformTypeNSView);

can also confirm that the windows equivalent of this works fine:

view->attached(glfwGetWin32Window(editorWindow), Steinberg::kPlatformTypeHWND);

You must call the attach method with a NSView object not a NSWindow object.