Q:

Xcode Issue Adding Action

I'm working on a UI.  When I want to add an action, I drag from the control to the code in the assistant editor.  When the action is created, the code is inserted in to the middle of other functions, causing errors.  This has been happening more and ore frequently.  I even updated Xcode to the latest (7.3.1), to try and fix it.  Here's an example of what happens:
override func viewDidLoad() {
    super.viewDidLoad()
    @IBAction func doneClicked(sender: AnyObject) {
    }

    //self.navigationItem.setHidesBackButton(true, animated: false)
}

You can see that the doneClicked Action is inserted in to the middle of viewDidLoad.  The only way to fix it is to cut the code out of the middle of viewDidLoad, paste it lower, and then reconnect the action to the control.
It's getting really annoying.  Is there any way to fix it or is there a better way to create the actions without doing it this way?

A:

I think this is an Xcode bug because I have had similar problem too. After selecting Assistant Editor, you can fix this by selecting your file from automatic menu. This is what fixed it for me. You can refer the screenshot below.

