1

Im getting following error when I'm trying to connect outlet from my search bar. enter image description here

How can I solve that?

esea123
  • 45
  • 1
  • 6

9 Answers9

6
  1. Clean the Project

enter image description here

  1. Build and then Run.

  2. Try to add the outlets again, it will work this time.

Cons Bulaquena
  • 2,083
  • 2
  • 26
  • 24
5

I had this issue and I searched for several days how to fix this. I tried every solution that I could find, but without any luck.

I started looking in my git history on which branch the error occurred. I found a solution after several days.

I was working on a big project and I wanted to speed up my build speed and I changed some stuff in the build settings. The build setting that caused this issue was 'Swift compiler - Optimization level'. I changed the default value (No optimization) to 'Optimize for speed' and this caused the issue "Could not insert new outlet connection".

I hope I can help others with this solution because I lost a lot of time with it.

This is what it should be

1

In my case nothing worked

1) Deleting Class

2) Disconnecting the @IBOutlet

3) Manually Creating @IBOutlet Connections

The thing which did work was to restart XCode

After restart you can easily connect them without errors

Mujahid Latif
  • 596
  • 7
  • 18
0

Check that ViewController is correct or not?

Or

Clear class name in storyboard and edit again and also in class file

Or

quit Xcode and reopen and try that

Kathiresan Murugan
  • 2,783
  • 3
  • 23
  • 44
  • How can I check that ViewController is correct or not? Sorry, but I'm new to Xcode. I have no idea how to do any of those two possible solutions that you told me. – esea123 Jan 03 '18 at 12:07
0

Can you connect the other way, ie from the IBOutlet to the search bar ? In such a case, a clean of build border plus a reopen of the project should solve the problem.

claude31
  • 874
  • 6
  • 8
0

I know it's too late to answer this question. But, I think it was because you made a change to the class name on your swift file and it hasn't been saved yet. (The file is grayed out)

My solution: Try building it (Command + B), then connect it again.

jrbm
  • 11
  • 3
0

I created two classes with the same name in the project which gave me this error. By deleting one class file the issue got resolved.

novice
  • 461
  • 4
  • 12
0

What worked for me was to make the call the other way around, example: @IBOutlet weak var imageView: UIImageView!

I connected the .swift file to the .storyboard

-3

Error? Just check the locations of UI class file(swift) and UI builder file(xib or storyboard). Best is "Relative to Group"

Chea Thim
  • 1
  • 2