Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6.4 crashes in Swift breakpoint

In one project I'm using I can't set breakpoints in Swift code, Xcode always crashes when reaching one of them, doesn't matter if it's a "manual" or an exception breakpoint.

In other projects everything works as expected, only for one project Xcode 6.4 (6E35b) always crashes.

I tried cleaning, deleting derived data, resetting simulator, restarting Xcode/Mac - nothing helped at all.

Anyone else experiencing this problem and hopefully knows what helps?

EDIT Seems only to be the case on one machine (Xcode 6.4, 10.10.5), but not on the other (Xcode 6.4, El Capitan). But as I mentioned in the comments, reinstalling Xcode didn't help, are there some other preferences I could reset/delete?

EDIT2 Here's the Xcode crash log file: https://dl.dropboxusercontent.com/u/119600/Xcode_2015-08-12-074655_Stefans-iMac.crash

like image 352
swalkner Avatar asked Jul 20 '15 15:07

swalkner


People also ask

How do I set up a swift error breakpoint in Swift?

In the Breakpoint navigator, click the Add button (+) in the lower-left corner, and choose Swift Error Breakpoint. The app then pauses on the thrown error instead of the try!.

How do I Turn Off breakpoints in Xcode?

Xcode displays a breakpoint icon to indicate the location. Drag a breakpoint up or down to move it to another location; drag it away from the gutter to remove it. Click the breakpoint icon in the debug area toolbar to activate or deactivate all breakpoints.

How do I pause a line in Xcode?

Navigate to a line in your code where you want execution to pause, then click the gutter or line number in the source editor to set a breakpoint. Xcode displays a breakpoint icon to indicate the location. Drag a breakpoint up or down to move it to another location; drag it away from the gutter to remove it.

How do I debug an error in Swift?

In the Breakpoint navigator, click the Add button (+) in the lower-left corner, and choose Swift Error Breakpoint. The app then pauses on the thrown error instead of the try!. When an uncaught Objective-C error causes a crash, the debugger shows the crash in the AppDelegate or main method.


2 Answers

I would try uninstalling and reinstalling Xcode to see if it helps... I've heard of successes with this technique for similar issues.

Just delete the entire Xcode.app from /Applications, and reinstall from the .dmg. If you're not certain of the binaries and have time / bandwidth, consider re-downloading the .dmg.

If that doesn't work, try the following source control tricks (substitute "your favorite revision control" for "git"):

  • Try purging all objects not in source code control
  • Another approach: Check out the app again into a fresh repository (this will get even the files that may have been committed but ignored later).
  • If not under source code control, grab a .gitignore from here and add it to git, then check out into another directory (this will leave everything but source, interface builder, project files and resources/assets behind).

I'd suggest moving the breakpoint code to another location (such as making a function call and breaking either before or inside the function). However, if all Swift code has this problem, that may not work.

Finally, after making an interim commit (to roll back to), try it in Xcode 7 beta. Bit of a hassle because you have to upgrade to Swift 2.0, but if you keep the deployment target the same no iOS target changes are needed.

If this really is a burden and/or it's a small project, you could try creating a new project and migrating the files and storyboard over, but likely this is too much effort.

Either way, since you note it's pretty much all breakpoints in Swift code, file a bug with Apple's bug reporter. They really need to hear about issues such as this, since you don't seem to be alone in having this issue.

EDIT: Where are others seeing this issue? Maybe we can see commonality -- since this is only reported in Swift projects (so far). A colleague has seen this problem with breakpoints (as well as stepping through code) in Xcode 6.4 on 10.10.4. (I've seen Xcode 6.4 crashes in the past as well).

I see OS version 10.10.5 mentioned as a target where this happens (@swalkner); is this a beta? If OS 10.10.4/5 is the only place we see this, it might be significant. If it's a project/OS interaction, it might be tricky to reproduce / fix, but I'd encourage everyone to submit detailed bug reports to Apple (maybe even link this post).

Some points to note if you're seeing this:

  • Operating System Version
  • Hardware
  • Target: Simulator vs. Hardware; iOS vs WatchKit app.
  • Target SDK version(s)
  • Swift only? Or on an Objective-C only project? Mixed?
  • Only one project, or several?
like image 136
rholmes Avatar answered Oct 20 '22 05:10

rholmes


It's a longshot, but let me know if it's working:

uncheck the "Always show Dissasembly" check

Debug > Debug Workflow > Always Show Disassembly

In older versions of Xcode (<6.1):

Product > Debug Workflow > Show Disassembly When Debugging
like image 25
oronbz Avatar answered Oct 20 '22 04:10

oronbz