Fatal trap exceptions in Obj-C / Swift project

I’m starting to integrate Swift code into my Obj-C project. Everything’s been going smoothly but today, when I updated to Xcode 6.1, things hit the fan. I’m getting a number of “trap” exceptions from Swift code that was previously running fine.

The first crash is in my extension of UIFont. Here’s my code:

  • What is the fastest way to load a large CSV file into core data
  • How can I continuously play background music while switching to different views using swift?
  • Can I launch one app from other app on iPhone
  • how to add short sounds while swiping images in uiscrollview
  • Swift error: Reference to generic type Dictionary requires arguments in <…>
  • Share data between two or more iPhone applications
  • class func specialFont() -> UIFont {
        let font = UIFont(name: "FontName", size: 12.0)
        return font!

    This code was working fine before updating to Xcode 6.1, but now crashes with EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT), at dylddyld_fatal_error: 0x1fe1608c: trap. (BTW, I don’t have an exception breakpoint set.) Attempting to continue program execution doesn’t generate a crash log, it just enters an endless cycle of generating that exception. Again, code worked fine before Xcode 6.1 update.

    The second crash is especially strange because it only happens when debugging on a device, not on the simulator. Same exception info as above. Here’s the second bit of code that’s crashing:

    let tap = UITapGestureRecognizer(target: self, action: "didTap")

    Thanks for any help!


    Stack trace is below:

    0] dyld_fatal_error
    1] dyld_stub_binder
    4] Project.FileWhereCrashTriggers.methodTriggeringCrash
    5] @objc Project.FileWhereCrashTriggers.methodTriggeringCrash
    6] -- continued trace up to call of method crashing

    One weird thing about these crashes is that they don’t trigger the exception on the actual line of code, as you can see from the stack trace. They break in dyld_fatal_error.

    I can’t upload any console output because the app never actually crashes while running in Xcode – it calls endlessly similar to EXC_BAD_ACCESS. I triggered the crash in non-debug mode and then looked at the device logs using Organizer and this is what it offered:

    Exception Type: EXC_BREAKPOINT (SIGTRAP)
    Exception Codes: 0x0000000000000001, 0x00000000e7ffdefe
    Triggered by Thread: 0

    Dyld Error Message:
    Symbol not found: __TFSSCfMSSFT21_builtinStringLiteralBp8byteSizeBw7isASCIIBi1__SS
    Referenced from: /private/var/mobile/Containers/Bundle/Application/4ABA71F8-A6D1-4E4B-A452-DE339065310A/Project.app/Project

    Expected in: /private/var/mobile/Containers/Bundle/Application/4ABA71F8-A6D1-4E4B-A452-DE339065310A/Project.app/Frameworks/libswiftCore.dylib
    Dyld Version: 353.5

    2 Solutions Collect From Internet About “Fatal trap exceptions in Obj-C / Swift project”

    A clean build solved it for me (clean from XCode and delete app on device)

    After experimenting more, I was able to resolved these conflicts by using the @objc marker in my swift files in all swift methods that could get called by my Obj-C code, including init methods. For example, change override init(frame: CGRect) to @objc override init(frame: CGRect).

    As an aside: I’m still a bit confused by why the @objc flag wasn’t ‘required’ (although it may have been best practice) in Xcode 6.0 but suddenly was a requirement in Xcode 6.1.