1

I'm new to macOS programming and recently I started working on this project. Because I needed to share my ViewController and view with my Safari extension target, I ended up setting the view controller manually in AppDelegate:

let application = NSApplication.shared()

let initVC = ViewController.viewControllerWithNib()
let window = application.windows.first!
window.windowController?.contentViewController = initVC
window.contentViewController = initVC
window.makeKeyAndOrderFront(nil)

I just left Main.storyboard to include the application portion since I couldn't figure out how to remove the storyboard and just use a xib as a startup for my application. Curently, I'm getting the following warning:

Window Controller requires a content view controller, main.storyboard

I'm trying to figure out why the app is giving that warning and what's the way to get rid of it.

manman
  • 4,743
  • 3
  • 30
  • 42
  • "since I couldn't figure out how to remove the storyboard and just use a xib as a startup for my application" Well then, maybe that's what you should ask about. See for example this answer: http://stackoverflow.com/a/43399442/341994 – matt Apr 16 '17 at 20:30
  • @matt Thought that's implicit in the question, I can modify the title and the body to ask that question and then explain my workaround for it and the issue with the workaround – manman Apr 16 '17 at 20:40

3 Answers3

1

You should see the info.plist, I remember there is a need to delete the name NSMainxxxx.

Simon
  • 438
  • 4
  • 14
1

As Diven mentioned, there's also an entry in plist file, UIMainStoryboardFile which tells which storyboard needs to be used. The equivalent of it for nibs is NSMainNibFile. But in addition to that, there were several other steps that I needed to do for replacing the storyboard fully with a nib which are mentioned in this post. Generally, what you need is following steps:

  1. Add a new nib to your project and choose a name, e.i. MainNib. You can choose an Application nib template
  2. Go to project, under target -> General -> Deployment Info -> choose the nib you created as Main interface
  3. Go to your nib, as mentioned in here, add a blue object and assign its class to AppDelegate and then ctrl+drag/drop from File owner to that object and choose that one to be the delegate.

I updated the project with these changes.

Community
  • 1
  • 1
manman
  • 4,743
  • 3
  • 30
  • 42
0

There's no more Info.plist you can easily select the target and check the Info tab. And there's Main nib file base name there. enter image description here

William Hu
  • 15,423
  • 11
  • 100
  • 121