P77, Unable to load nib file (window will not load)


#1

I get the message Unable to load nib file: MainMenu, exiting (Ironically, the build shows up as successful but no window pops up.) I am using Swift 4.0 with Xcode 9. Any suggestions?

My MainWindowController.swift code:
import Cocoa
class MainWindowController: NSWindowController{
override var windowNibName: NSNib.Name?{
return NSNib.Name(rawValue: “MainWindowController”)
}
}

My AppDelegate.swift code:
import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

var mainWindowController: MainWindowController?
func applicationDidFinishLaunching(_ aNotification: Notification) {
    //Create a window controller
    //Put the window of the window controller on screen
    //set the property to point ot the window controller
    
    let mainWindowController = MainWindowController()
    mainWindowController.showWindow(self)
    self.mainWindowController = mainWindowController
}

#2

The code in the book does not work. I recently bought this book and none of the programs work.


#3

Does the above code actually compile at all? The use of the unicode curly quote characters in the string should set alarm bells ringing.


#4

I do not have curly quotes in my code.


#5

I get Build Succeeded, then in the bottom pane I get the error message: 2018-04-03 11:25:04.890160-0500 RGBWell[10057:2124151] Unable to load nib file: MainMenu, exiting

I have an RGB Wheel that works using the NSView Controller, so sad though, a brand new book that = useless.


#6

Here is the MainWindowController.swift contents:
import Cocoa
class MainWindowController: NSWindowController {
override var windowNibName: NSNib.Name? {
return NSNib.Name(rawValue: “MainWindowController”)
}

@IBOutlet weak var mySlider: NSSlider!

}

Here are the AppDelegate.swift contents:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

var mainWindowController: MainWindowController?


func applicationDidFinishLaunching(aNotification: NSNotification) {
    let mainWindowController = MainWindowController()
    mainWindowController.showWindow(self)
    self.mainWindowController = mainWindowController
}

func applicationWillTerminate(aNotification: NSNotification) {
    // Insert code here to tear down your application
}

}


#7

Check to make sure that MainMenu.xib file is in your project.

If the file is missing, Xcode produces the following error message, which you are getting.

Unable to load nib file: MainMenu, exiting

If the file is in the project, start from scratch by creating a new project.


#8

I started everything from scratch and it seems to be working. I followed an IBOutlet and it seemed to be going to some Dummy file I had called DeleteMe…