7

When I try to drag and drop an IB outlet from a UIView into my ViewController.swift, XCode crashes (when I press OK after typing a name for the IBOutlet). A popup appears saying: "XCode quit unexpectedly": Ignore, report, reopen. The report says lots of verbose, the most notable warnings are these:

UNCAUGHT EXCEPTION (NSInvalidArgumentException): +[IDESwiftSourceCodeGenerator isTeardownCounterpart:]: unrecognized selector sent to class 0x1159415c0
prepareToAddSourceCodeForCounterparts:documentLocationForCounterpartBlock:addSourceCodeForCounterpartBlock:options:error:] (in IDEKit)
  8  0x000000011588a13f -[IDESwiftSourceCodeGenerator prepareToAddPropertyWithName:type:inClassItem:options:error:] (in IDELanguageSupportUI)

I have other IBOutlets working well for UILabels and a Table View, so I do not understand, why this happens.

I am fairly new to Xcode, if you need any additional info to detect what is going wrong, I will gladly provide it. Already tried the usual Clean, Rebuild, Reopen, Restart, and Simulator reset just in case....

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Josh
  • 6,251
  • 2
  • 46
  • 73
  • 1
    Your project might be corrupt. I know it's a PITA but it happens sometimes. You might try rebuilding your project from scratch. Also try the drag and drop with someone else's Mac. – Mike Crawford May 18 '15 at 09:43
  • 2
    Try dropping to a different line usually to a blank line with no other line in top and bottom of it – Zell B. May 18 '15 at 09:46
  • @zellb Sorry, XCode is still crashing – Josh May 18 '15 at 12:16
  • Unfortunately this is between you and Apple. Stack Overflow is about programming, not about some app that is crashing on your Mac — even, alas, if that app happens to be Xcode. – matt May 18 '15 at 14:39
  • 1
    The IDE directly affects programming, even, alas, if you have no clue about what the solution is. @matt – Josh May 18 '15 at 14:55
  • 1
    @matt there are 98k posts tagged with Xcode, i guess none of them are relevant then? – Seamus Apr 27 '16 at 13:32
  • @BROK3NS0UL How to use Xcode to program, relevant. Xcode is crashing, not relevant (but file a bug with Apple). – matt Apr 27 '16 at 13:45

2 Answers2

17

Ok, I tried different ways towards desired purpose. I discovered an esoteric workaround:

1-Type this in the .swift file:

@IBOutlet var tableView: UITableView!

2-Do the drag and drop FROM the line of code above TO the UIView in the story board, NOT the other way around, otherwise: XCode will crash.

3-Voila! Bug evaded.

Josh
  • 6,251
  • 2
  • 46
  • 73
0

Continuous crashes for me also on Xcode 9.4.1 and 10_GM - after linking IBOutlet with XIB.
Solution: clean up Derived data /Users/****/Library/Developer/Xcode/DerivedData.
Based on: https://forums.developer.apple.com/thread/76730

Octav
  • 443
  • 3
  • 9