How To: Simple UIViewController w/ .xib using XCode15

107 Views Asked by At

I'm having issues creating a simple UIViewController in XCode15.

I want to create a .xib and accompanying .swift file as a controller.

Things seemed to have changed and I can't create a UIViewController with .xib.

I'm facing some error where it says the view outlet is not set.

I've tried everything.

Is there something wrong within the didSelectRowAt method?

Below are some screenshots of the latest attempt.

Any help (even step by step from scratch) would be much appreciated.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

1

There are 1 best solutions below

3
son On BEST ANSWER

You have it configured incorrectly. Actually, CustomVC.swift should be assigned to File's Owner. Then set the View as a referencing outlet for the File's Owner. You're assigning a UIView (which is CustomVC on xib file) to an instance of UIViewController.

Those steps are:

enter image description here

enter image description here

Right click then drag to View.

enter image description here

Note: I don't know why you're starting from scratch, but here's an alternative:

XCode -> Command + N to create new file -> on iOS tab select Cocoa Touch Class -> Click Also create XIB file