InDesign CC Mac: "Cannot open resource file" popup message when loading a Nib in my plugin
We have a fairly simple plug-in to InDesign, which we have been maintaining since the pre-CS days. We’re porting it to CC now. Everything is working on both Windows and Mac, with one problem.
The plug-in shows a File Save dialog, which is customized with a couple of extra controls to get additional information from the user about the file being exported. As far as I know, there’s no way to do this with the InDesign SDK directly, so we do it with platform-specific code and resources. On Windows, we do this by calling GetSaveFileName in the Windows API and setting a custom .rc resource and “hook” function with OFN_ENABLETEMPLATE and OFN_ENABLEHOOK. On Mac, up until InDesign CC, we’ve been calling the Carbon function NavCreatePutFileDialog, with an old-style .r file and an event proc handling kNavCBCustomize et al. This has all worked great for a long time.
However InDesign CC on Mac is 64-bit only, and Carbon won’t work with that. So, we’ve taken the leap into Cocoa and implemented this with [NSSavePanel setAccessoryView:], where we load a custom NSView from a Nib embedded in our plug-in bundle. And this works just fine too. However, when the plug-in code calls [NSNib initWithNibNamed:bundle:], InDesign CC pops up an alert box saying, “Cannot open resource file.” Yet, the resource (the Nib) is obviously being loaded just fine. So the user has to dismiss this seemingly spurious alert box before being able to proceed. Once the alert is dismissed, the NSSavePanel works fine, with our custom NSView.
I can tell that the popup alert is coming from InDesign itself, rather than from some underlying Mac subsystem such as Cocoa, because it has the title “Adobe InDesign” and the dark gray background like the rest of InDesign CC, and the OK button has an orange highlight around it. It’s clearly not a standard Mac thing like an NSAlert. And if I make the same calls to [NSSavePanel setAccessoryView:] et al in a standalone application, obviously no such popup is shown.
It seems that somehow our call to load the Nib file is triggering some kind of hook in InDesign. My guess is that it’s a hook set up for InDesign to load its own resources, which is erroneously hooking into our plug-in’s functionality.
I’ve tried both of the approaches to loading the Nib file listed here:
http://stackoverflow.com/a/5855561/3207828
And they both work, and the Nib is loaded, and we can get our NSView from it and use it in the NSSavePanel. But whether we call [NSNib initWithNibNamed:bundle:], or [NSViewController initWithNibName:bundle:], InDesign CC shows the message box as soon as the call to load the Nib is made.
Why is InDesign CC showing the “Cannot open resource file” message, and how can it be prevented?
Thanks,
Dan