Outlets and Actions dont show up in IB

Hi guys, I'm having a headache with this bug.


I installed Mac OS Catalina beta 4 and Xcode 11 beta 4. The problem is that when I create a new UIViewController with xib enabled, Actions and Outlets don't show up at IB. Not sure what is happening.


I though it was a bug from Xcode 11. I installed Xcode 10.3 and it's still happening!


Any ideas?


Here is my vc code :/ This really weird


import UIKit

class AViewController: UIViewController {

    @IBOutlet weak var aLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

Accepted Reply

Hi guys, this was finally solved. It was an Xcode bug. Just update to Mac OS Catalina beta 5 and Xcode 11 beta 5. You may have to remove your files and add them again for this to work 🙂

Replies

Actions and Outlets don't show up at IB


What do you mean ? Sorry if that's basic questions:

- That when you control drag from IB to code, you don't get the pop up with IBAction or IBOutlet ?

If so, have you properly defined the class of the UIViewController in IB as being AViewController


- That you cannot connect from the object in IB to the IBOutlet you have defined in code ?

Same check to be done,

plus making sure that object in IB has the correct type

Hi @Claude31, let me clarify:


I created a new flie of type UIViewController, with create xib option enabled.


After that, I added an IBOutlet as follows:

@IBOutlet weak var aLabel: UILabel!


When I go to my xib, there is no Outlet to be connected in the Connections Inspector with name aLabel. I can only see my view with a warning sign at the right.


My AViewController is correctly set on the Identity and Attributes inspector

If I understand correctly what you've done so far,

you created a file for a subclass of UIViewController (I assume you called it MyViewController)

you created a xib dedicated to its UIViewController ; that means it is not in the storryboard.

So, you have 2 files: MyViewController.swift and MyViewController.xib

Exact ?


If so, you should:

- check that the file owner is of MyViewController.xib class is MyViewController

- create a UILabel in the xib file, by dragging a UILabel object inside in IB

- drag from the white circle on the left of

@IBOutlet weak var aLabel: UILabel!

to the UILabel in IB


Note: why didn't you create the UIViewController in the storyboard ?

To do so:

- keep MyViewController.swift file

- remove MyViewController.xib

- in the storyboard, drag a ViewController

- select it, open the identity inspector

- set the class to MyViewController

I am having this same issue with a new ViewController in XCode11. Everything is set up correct, and I have checked it 100 times. Did you find a solution?

Looks like a weird bug when adding a new ViewController. I deleted the reference to the new files and re-added them, and all of the outlets showed up correctly.

An option clean Build Folder could also solve the problem. That looks like a missing reference somewhere in XCode…

Hi guys, this was finally solved. It was an Xcode bug. Just update to Mac OS Catalina beta 5 and Xcode 11 beta 5. You may have to remove your files and add them again for this to work 🙂