NSOpenPanel fails with NSUserDefaults domain 'nil' under SDL2 with macOS Sequoia . SDL2 C++

This is with SDL2 and C++

Due to the new security design of Sequoia involving the sandboxed helper processes (via ViewBridge) to show open/save panels, my existing code for invoking Open/SaveAs/FolderSelect dialogs no longer works and instead terminates with ViewBridge Code=14 "(null)" error.

Even in the simplest of forms such as;

nfdresult_t NFD_OpenDialogN_With_Impl(nfdversion_t version,
      nfdnchar_t** outPath,
      const nfdopendialognargs_t* args) {

   nfdresult_t result = NFD_CANCEL;
   NSOpenPanel* dialog = [NSOpenPanel openPanel];
   if ([dialog runModal] == NSModalResponseOK) {
      result = NFD_OKAY;
   }

   return result;
}

...Will no longer work.

My Question is essentially, how can I resolve this NSUserDefaults domain empty/nil issue ( currently I don't pass anything for sharing defaults during the process ).

Dump of fault provided in crash.txt ( the program doesn't actually crash, it just doesn't invoke the file-open dialog )

Accepted Answer

This was a very painful one to find so I'm going to write as much as I can here about how to fix it if you encounter the same.

First, this will likely only apply to those using CMake for their builds.

It comes down ultimately to the MACOSX_BUNDLE facility needing to be reading the right Info.plist and not default to its internal cmake one. If you don't specify an explicit Info.plist to use you'll likely run in to this drama.

set_target_properties(project_name PROPERTIES
          MACOSX_BUNDLE TRUE
          MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
NSOpenPanel fails with NSUserDefaults domain 'nil' under SDL2 with macOS Sequoia . SDL2 C++
 
 
Q