158

I'm getting the error ...

Command failed due to signal: Segmentation fault: 11

... when trying to compile my Swift app. I'm using Xcode 6.1, trying to build for an iPhone 5 on iOS 8.1.

My Code

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var username: UITextField!
    @IBAction func signIn(sender: AnyObject) {

        PFUser.logInWithUsernameInBackground(username.text, password:"mypass") {
            (user: PFUser!, error: NSError!) -> Void in
            if user != nil {
                println("Logged In")
            } else {

                func myMethod() {
                    var user = PFUser()
                    user.username = username.text
                    user.password = " "
                    user.signUpInBackgroundWithBlock {
                        (succeeded: Bool!, error: NSError!) -> Void in
                        if error == nil {
                            // Hooray! Let them use the app now.
                        } else {
                                println("Signed Up")
                        }
                    }
                }

             println(error)
            }
        }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        Parse.setApplicationId("key here")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

And the error text!

CompileSwift normal arm64 /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/ViewController.swift
    cd /Users/Alec/Desktop/Re-Chat/Re-Chat
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/ViewController.swift /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/AppDelegate.swift -target arm64-apple-ios8.0 -Xllvm -aarch64-use-tbi -target-cpu cyclone -target-abi darwinpcs -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -I /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Products/Debug-iphoneos -F /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Products/Debug-iphoneos -F /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat -g -import-objc-header /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/Re-Chat-Bridging-Header.h -module-cache-path /Users/Alec/Library/Developer/Xcode/DerivedData/ModuleCache -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Re-Chat-generated-files.hmap -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Re-Chat-own-target-headers.hmap -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Re-Chat-all-target-headers.hmap -Xcc -iquote -Xcc /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Re-Chat-project-headers.hmap -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Products/Debug-iphoneos/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/DerivedSources/arm64 -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController~partial.swiftdoc -Onone -module-name Re_Chat -emit-module-path /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController~partial.swiftmodule -serialize-diagnostics-path /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController.dia -emit-dependencies-path /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController.d -o /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController.o
0  swift                    0x0000000108145a68 llvm::sys::PrintStackTrace(__sFILE*) + 40
1  swift                    0x0000000108145f54 SignalHandler(int) + 452
2  libsystem_platform.dylib 0x00007fff86631f1a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fd0ac1eb010 _sigtramp + 633049360
4  swift                    0x00000001075d4517 swift::Lowering::SILGenFunction::emitClosureValue(swift::SILLocation, swift::SILDeclRef, llvm::ArrayRef<swift::Substitution>, swift::AnyFunctionRef) + 1303
5  swift                    0x00000001075c599e swift::Lowering::SILGenFunction::visitFuncDecl(swift::FuncDecl*) + 190
6  swift                    0x000000010760987c swift::Lowering::SILGenFunction::visitBraceStmt(swift::BraceStmt*) + 380
7  swift                    0x000000010760c8e8 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Stmt*) + 152
8  swift                    0x000000010760a0a5 swift::Lowering::SILGenFunction::visitIfStmt(swift::IfStmt*) + 757
9  swift                    0x000000010760c8f6 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Stmt*) + 166
10 swift                    0x00000001076097e8 swift::Lowering::SILGenFunction::visitBraceStmt(swift::BraceStmt*) + 232
11 swift                    0x000000010760c8e8 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Stmt*) + 152
12 swift                    0x00000001075d52dd swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 205
13 swift                    0x00000001075b4234 swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*) + 196
14 swift                    0x00000001075eef71 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 97
15 swift                    0x00000001075e1866 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 2870
16 swift                    0x00000001075e24da swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 6058
17 swift                    0x00000001075cfa0b swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*) + 235
18 swift                    0x00000001075ae824 swift::Lowering::RValueSource::materialize(swift::Lowering::SILGenFunction&) && + 196
19 swift                    0x0000000107604a69 swift::Lowering::RValueSource::materialize(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::SILType) && + 233
20 swift                    0x00000001075f371c swift::Lowering::SILGenFunction::emitInjectOptionalValueInto(swift::SILLocation, swift::Lowering::RValueSource&&, swift::SILValue, swift::Lowering::TypeLowering const&) + 268
21 swift                    0x00000001075e9b8d swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 36445
22 swift                    0x00000001075e3e2b swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 12539
23 swift                    0x00000001075e202b swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 4859
24 swift                    0x00000001075cfab6 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 22
25 swift                    0x00000001075bffc4 (anonymous namespace)::ArgEmitter::emitExpanded(swift::Lowering::RValueSource&&, swift::Lowering::AbstractionPattern) + 836
26 swift                    0x00000001075bf582 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::RValueSource&&, swift::Lowering::AbstractionPattern) + 98
27 swift                    0x00000001075b7ff8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1128
28 swift                    0x00000001075b751a swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 58
29 swift                    0x00000001075e0d81 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 81
30 swift                    0x00000001075ea00d swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 237
31 swift                    0x0000000107609829 swift::Lowering::SILGenFunction::visitBraceStmt(swift::BraceStmt*) + 297
32 swift                    0x000000010760c8e8 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Stmt*) + 152
33 swift                    0x00000001075d4ee0 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 256
34 swift                    0x00000001075b3659 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 233
35 swift                    0x00000001075cea93 swift::ASTVisitor<SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 355
36 swift                    0x00000001075cd7eb SILGenType::emitType() + 203
37 swift                    0x00000001075c85ae swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
38 swift                    0x00000001075b555b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 395
39 swift                    0x00000001075b581a swift::SILModule::constructSIL(swift::Module*, swift::SourceFile*, swift::Optional<unsigned int>) + 314
40 swift                    0x00000001075b5968 swift::performSILGeneration(swift::SourceFile&, swift::Optional<unsigned int>) + 72
41 swift                    0x000000010748be18 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 3432
42 swift                    0x000000010748996d main + 1677
43 libdyld.dylib            0x00007fff8aa4c5c9 start + 1
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/ViewController.swift /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/AppDelegate.swift -target arm64-apple-ios8.0 -Xllvm -aarch64-use-tbi -target-cpu cyclone -target-abi darwinpcs -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -I /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Products/Debug-iphoneos -F /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Products/Debug-iphoneos -F /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat -g -import-objc-header /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/Re-Chat-Bridging-Header.h -module-cache-path /Users/Alec/Library/Developer/Xcode/DerivedData/ModuleCache -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Re-Chat-generated-files.hmap -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Re-Chat-own-target-headers.hmap -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Re-Chat-all-target-headers.hmap -Xcc -iquote -Xcc /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Re-Chat-project-headers.hmap -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Products/Debug-iphoneos/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/DerivedSources/arm64 -Xcc -I/Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController~partial.swiftdoc -Onone -module-name Re_Chat -emit-module-path /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController~partial.swiftmodule -serialize-diagnostics-path /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController.dia -emit-dependencies-path /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController.d -o /Users/Alec/Library/Developer/Xcode/DerivedData/Re-Chat-awwdkmqavitiqkcdsphwnhzhzzfb/Build/Intermediates/Re-Chat.build/Debug-iphoneos/Re-Chat.build/Objects-normal/arm64/ViewController.o 
1.  While emitting SIL for 'signIn' at /Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/ViewController.swift:14:15
2.  While silgen closureexpr SIL function @_TFFC7Re_Chat14ViewController6signInFS0_FPSs9AnyObject_T_U_FTGSQCSo6PFUser_GSQCSo7NSError__T_ for expression at [/Users/Alec/Desktop/Re-Chat/Re-Chat/Re-Chat/ViewController.swift:16:80 - line:45:9] RangeText="{
            (user: PFUser!, error: NSError!) -> Void in
            if user != nil {
                // Do stuff after successful login.

                println("Logged In")
            } else {

                func myMethod() {
                    var user = PFUser()
                    user.username = username.text
                    user.password = ""
                    // other fields can be set just like with PFObject


                    user.signUpInBackgroundWithBlock {
                        (succeeded: Bool!, error: NSError!) -> Void in
                        if error == nil {
                            // Hooray! Let them use the app now.
                        } else {
                                println("Signed Up")
                        }
                    }
                }


             println("error")
            }
        }"
rrauenza
  • 6,285
  • 4
  • 32
  • 57
Alec.
  • 5,371
  • 5
  • 34
  • 69
  • The code shown in the error and the code you have posted are different. Your code is for logging in, the error code is the signup methods. Have you set a breakpoint in the closure to try and identify the problem? – Paulw11 Oct 24 '14 at 23:21
  • You don't need to guess it. Type `xcodebuild -verbose` from terminal where your project resides, and see exactly what the error is, where it is etc. – oyalhi Jun 19 '17 at 10:30

57 Answers57

94

You can get this error when the compiler gets too confused about what's going on in your code. I noticed you have a number of what appear to be functions nested within functions. You might try commenting out some of that at a time to see if the error goes away. That way you can zero in on the problem area. You can't use breakpoints because it's a compile time error, not a run time error.

Ron B.
  • 1,091
  • 1
  • 7
  • 13
  • 1
    Thanks but it turned out to be something to do with the architectures. Weird, huh? – Alec. Nov 28 '14 at 15:55
  • 3
    @ParanoidAndroid can you please detail what was the problem? i'm getting this issue also – Alex Jan 12 '15 at 22:11
  • I'm stuck on this error too. I was creating extensions from a bigger class and moving some functions from the big class into the extension of it. I created a couple files as extensions fine but as soon as I created a 4th one I started getting this error. #swiftisnotready.... grrr – C0D3 Feb 03 '15 at 16:20
  • @c0d3Junk13 I met extension problem too, and it is caused by function name is same as the class name. – Zhenshan Yu Feb 20 '15 at 16:59
  • I got it for not specifying an optional parameter (second parameter), seems like the tertiary operator before it confuses Xcode 6.3 `addPointforTeamAtPosition(command == extensionCommandTeam1Point ? 0 : 1, pointKind: .Regular)`. – Rivera Apr 12 '15 at 12:48
  • Good point @Rivera. Same issue with this: updateAnswerCount(++numAttempts == 1 ? &hitCount : &missCount) , which breaking out into a regular if-else did the trick. – Kevin Owens Jul 30 '15 at 05:12
  • The current Xcode beta will get this error if you define ambiguous initialisers. The cases I've noticed this most is when I set default parameter values, such that one initialiser using default (excluded) parameters becomes harder to distinguish from another initialiser for the same class. There are probably a bunch of things that can cause this, but the error log usually gives some clue to the location of the real problem, it's just not a very useful error, so needs reporting to Apple when you get a chance. – Haravikk Aug 22 '15 at 15:36
  • Removing some methods from within a protocol/extension resolved the issue for me :) – Henry Heleine Dec 09 '15 at 17:00
  • @Alec, Same here, architecture made Xcode crash and produce this error. It's actually really interesting :) – OhadM Jun 27 '17 at 17:50
  • I got this with Xcode 9.3 and aa `AnyObject` cast that used to work in 9.2. I used `NSValue` instead. – Rivera Apr 11 '18 at 22:10
  • This is correct in my case: `lazy var sfAmount = BehaviorRelay(value: order.customServiceFeePercent > 0 ? 0 : order.customServiceFeeAmount)` => this seems to confuse XCode – Chinh Nguyen Jun 28 '19 at 07:09
51

I recently encountered the same problem, and I will try to generalise how I solved it, as a lot of these answers are to spesific to be of help to everyone.

1. First look at the bottom of the error message to identify the file and function which causes the segmentation fault.

Error message

2. Then I look at that function and commented out all of it. I compiled and it now worked. Then I removed the comments from parts of the function at a time, until I hit the line that was responsible for the error. After this I was able to fix it, and it all works. :)

eivindml
  • 2,197
  • 7
  • 36
  • 68
43

For anyone else coming across this... I found the issue was caused by importing a custom framework, I have no idea how to correct it. But simply removing the import and any code referencing items from the framework fixes the issue.

(╯°□°)╯︵ ┻━┻

Hope this can save someone a few hours chasing down which line is causing the issue.

Chris Wagner
  • 20,773
  • 8
  • 74
  • 95
  • 1
    I've experienced the same problem in Xcode 7. The problem really was the few lines of code I've added to my swift file. These lines are consuming a component from 3rd party library. In my case it's Eureka. Once I removed the lines I've added. It got built perfectly – Asanga Dewaguru Jan 29 '16 at 04:13
  • I had deleted a protocol & some classes were still using it. XCode should have highlighted them but it didn't in my case. Thanks – harsh_v Mar 28 '16 at 09:18
  • 3
    Was Eureka in my case too, when updating to Xcode 7.3. Changed to v1.5 and did pod install, then all was well. – Lyck Apr 12 '16 at 11:36
  • Just noting that this didn't work for me until I cleaned the project (after replacing the custom framework / import). Thanks for your answer, certainly saved me some time. – AddisDev Apr 28 '16 at 13:34
  • 1
    Updating the pod and reinstall lib done the trick to me thank you for your answer – Kamal Upasena Jul 04 '16 at 04:10
  • I created a new project and as soon as I write any code, the error arises and after deleting the code, it works fine. Very annoying behavior in Xcode 8.1, no fixed solution is available here. – Jas_meet Nov 28 '16 at 12:06
  • 1
    I am also having issues with Eureka, now version (5.0.0) – agandi Sep 03 '19 at 13:52
  • I am also having the same issue again with Eurika after updating Xcode to version 12.0.1 – Atif Khan Oct 21 '20 at 12:08
16

For me, this was caused by a change in the Parse SDK syntax in Swift 2.0. If you are using Parse and you upgrade to Swift 2.0, the following syntax changes:

Swift 1.2:

myPFQuery.findObjectsInBackgroundWithBlock({ (queryResults: [AnyObject]?, error: NSError?) -> Void in

    // CODE

})

Swift 2.0:

myPFQuery.findObjectsInBackgroundWithBlock { (queryResults: [PFObject]?, error: NSError?) -> Void in

    // CODE

}

The removal of the first '(' and the last ')' is what was causing the biggest problem. Took me AGES to find this!

AT3D
  • 857
  • 1
  • 8
  • 13
  • This is definitely the culprit, however, your line of code does not do the fix for me. Any new details? – Lucas Azzopardi Dec 06 '15 at 01:41
  • Are you sure you have found all instances and changed them all? Also, I believe calls to the following have changed as well (removal of fist and last parenthesis so code should read like the following)... pfObject.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in //code } – AT3D Dec 07 '15 at 11:13
  • the exact one. Working fine – SARATH SASI Dec 15 '15 at 09:04
  • So trailing closure syntax was causing this issue as well? – Beltalowda Mar 19 '18 at 19:43
9

I hit this error. After some frustration I tried Xcode clean and everything started working again. Just leaving this here for future reference.

Victor Zimmer
  • 197
  • 2
  • 2
7

When I got this error converting from Swift to Swift 2.0, it clearly indicates a particular file (blahClass.swift) that has the problem, then it outlined all of the warnings & errors in the error message text. I went through and resolved these manually and now the app compiles fine.

William T.
  • 12,831
  • 4
  • 56
  • 53
  • 3
    Just adding another datapoint here. I was also getting this error during a Swift 2 migration. I ended up opening the file that it was failing on and commenting out most of the code. The app then compiled and I was able to uncomment the code a few lines at a time to track down the problem. – Chad Pavliska Oct 19 '15 at 16:59
7

For me this was caused by some of my code. The detailed compiler output in XCode actually pin-pointed the method where it was crashing.

I then commented out all the code in the method, made it return nil, and it did compile. I then re-implemented the method using different and much simpler code, and it worked.

I filed a bug report with Apple. This is the - admittedly somewhat crazy - code that caused the crash in XCode 7 / Swift 2.0.

  func numberAndTitleFromDirectoryName(dirName: String) -> (Int, String)? {
    let components = dirName.characters.split(maxSplit: 1, allowEmptySlices: false) { $0 == " " }.map { String($0) }.map { String($0) }
    if let number = components.first?.toInt() {
        if let title = components.last {
            return (number, title)
        }
    }
    return nil;
  }

I guess I got a little over-excited using the map function there... The new version is a lot simpler and also more human comprehensible. Still the compiler shouldn't crash. At worst it should show some errors. The code as is worked in Swift 1.x

n13
  • 6,843
  • 53
  • 40
7
object.doubleValue = dict["doublevalue"] as! Int

I found the reason after rolling back each step I made.... force casting to Int for a Double variable

SoliQuiD
  • 2,093
  • 1
  • 25
  • 29
4

Easy fix if using git.

1) In terminal:

git stash

2) Seg fault disappears.

3) Run the app.

4) In terminal:

git stash pop

5) Xcode now tells you the real problem.

Andrew Schreiber
  • 14,344
  • 6
  • 46
  • 53
  • 1
    Hey man ! I wish to thank you so much. You saved me a strong headache and much time and effort ! – stefat Sep 12 '16 at 15:48
4

I had similar issue in with Xcode 7.3 and iOS 9.3. Command failed due to signal: Segmentation fault: 11

Screenshot

Basic steps such as Clean (cmd+shift+k) code, Delete derived data and Quit Xcode didn't work.

There was some culprit in my code.

It was [txtUserName.text.characters.count = 0]

In your case Review your code and fix the culprit.

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
  • 15
    Note to self, if your code doesn't work, follow the above helpful hint of "Review your code and fix the culprit", who knew.... – Stu P. Oct 04 '16 at 16:52
3

One of case, is that you have named datatype of getter variable like its name. For example:

var someInstance: someInstance {...

Update #1. Keep attention on _a variable which isn't Int, and you forget to point right return type. Issue happens in more than two operands of infix operator.

function getInt(value: Int) -> Int {
    return _a? ?? _b?.count ?? 0
}
dimpiax
  • 12,093
  • 5
  • 62
  • 45
3

Any crash is a compiler bug (whether or not your code is valid). Try the latest beta and if it still crashes file a bug report at bugs.swift.org. The Swift team are very responsive on these.

Joseph Lord
  • 6,446
  • 1
  • 28
  • 32
2

I got rid of this error by following.

I had many frameworks added in "Link Binary With Libraries" and was using a bridging header as well.

I re-added all the frameworks and added the bridging header again. This solved my issue.

Vakas
  • 6,291
  • 3
  • 35
  • 47
2

I'm using Xcode 8.3/Swift 3

I used @Ron B.'s answer to go through all the code and comment out different functions until I got a successful build. It turns out it was async trailing closures that was causing my error:

My trailing closures:

let firstTask = DispatchWorkItem{
     //self.doSomthing()
}
let secondTask = DispatchWorkItem{
     //self.doSomthingElse()
}

//trailing closure #1
DispatchQueue.main.asyncAfter(deadline: .now() + 10){firstTask}

//trailing closure #2 
DispatchQueue.main.asyncAfter(deadline: .now() + 20){secondTask}

Once I used the autocomplete syntax the Segmentation fault: 11 was Gone

//autocomplete syntax closure #1
DispatchQueue.main.asyncAfter(deadline: .now() + 10, execute: firstTask)

//autocomplete syntax closure #2
DispatchQueue.main.asyncAfter(deadline: .now() + 20, execute: secondTask)
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
2

enter image description here

I have same problem so I tried switch Optimization Level to Fast, Single-File Optimization[-O] instead of Fast, Whole Module Optimization then it worked, built, archive to Appstore succeed.

Some frameworks we used that need to refactor to adapt with Fast, Whole Module Optimization level I think. But I still did not find those framework.

HaiN
  • 917
  • 11
  • 31
2

In my case this happened in Xcode 11 beta 3 with Swift 5 and using SwiftUI.

My View has a @State property like this:

 @State private var normInfo: NormInfo?

the issue got solved by explicitly initializing it with nil.

Germán
  • 4,525
  • 3
  • 31
  • 37
1

I had that code 11 when trying to build for release scheme. It pointed out one viewcontroller class (swift) that had this piece of code inside:

 required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    stuff...
}

The problem was that when I have added superclass to it, I forgot to also implement init. So that super.init caused compiler error Segmentation fault: 11 So if you have such problem it's good idea to check also any superclasses.

gogel
  • 31
  • 3
1

I also had the Segmentation Fault 11, when importing a framework made by myself (yeah, felt really dumb).

After developing the framework for months and integrating it into a main project with intermixed Obj-C and Swift, importing to Obj-C was a no-problem, but as soon as I wrote the import MySwiftProject in Swift, all hell broke loose.

Long story short, the problem was that I created some custom methods that provide typification for NSNotifications using closures, for example:

func post(a : Int, b : String)
{
    NSNotificationCenter.defaultCenter().postNotification("notification", object: nil, userInfo: ["a" : a, "b" : b])
}

func observe(block : (a : Int, b : String) -> ()) -> NSObjectProtocol
{
    return  NSNotificationCenter.defaultCenter().addObserverForName("notification", object: nil, queue: nil)
    {
        (n : NSNotification!) -> () in

        // Unwrap the notification payload and provide types
        if let a = n.userInfo?["a"] as? Int, let b = n.userInfo?["b"] as? String
        {
            block(a, b)
        }
    }
}

(Actually, the code above I did with a template, but that's another story)

The main culprit? This:

func ... -> NSObjectProtocol

Apparently, Apple can use NSObjectProtocol in the declaration of NSNotification's methods, but when I do, it introduces a Segfault 11. Replacing NSObjectProtocol to AnyObject solved the crash.

Unfortunately, this might not solve your issue, since segfault 11 is simply a generic crash of the compiler, but you can take steps to solve it. It took me around 2 hours, but this is what I did:

  1. Create a new project, replicating the structure you had. In my case, I created a single view controller swift project, and added a swift framework inside as another project.
  2. Copy all the original code from one to another.
  3. Go to the compilation phase, and start removing files to compile, try disabling pieces of code that are very swift-hacky (like my NSNotification typification).
  4. Every time you do a change, do a clean (+K), build (+B) and fix any errors.
  5. Repeat from 3 until the segmentation fault goes away.
Can
  • 8,502
  • 48
  • 57
1

In my case the reason was having a class declared within another class within an extension.

extension classOrig {
    class classChild {
        class classGrandChild {
            static let aVariable : String = "SomeValue";
        }
    }
}

This generated the error on my side. I had several frameworks in my project, yet it did not happen before.

sharkbait
  • 2,980
  • 16
  • 51
  • 89
1

I also struggled with this for a while. I upgraded my code to Swift 2 with Xcode 7.2 and for me the problem was this:

self.mainScrollView.documentView!.subviews.reverse() as! [MainSubView]

Which I had to change to:

(self.mainScrollView.documentView!.subviews as! [MainSubView]).reverse()
Michael
  • 76
  • 6
1

I got this error when I was overriding a property in a subclass and I didn't repeat the property's declaration exactly.

Base class:

var foo: String! {return nil}

Subclass:

override var foo: String {return "bar"} // missing the implicit unwrap operator

Murray Sagal
  • 8,454
  • 4
  • 47
  • 48
  • How does this answer the question ? – Thomas Ayoub Mar 09 '16 at 14:23
  • @Thomas. It doesn't. But based on the many other similar responses -- "this is how I got that error... " -- it seemed ok to contribute my experience with this error in the hope that it would save someone else some frustration. Lemme know if you think it's inappropriate. – Murray Sagal Mar 09 '16 at 17:28
  • @MurraySagal something like this was the cause for me too – larromba May 19 '16 at 13:44
1

For me it's because I have two bundles with the same name.

Lumialxk
  • 6,239
  • 6
  • 24
  • 47
1

Read the debug message carefully.

in my case, I encountered this error because I used a single '=' instead of double '=' by mistake in if-statement.

if aString.characters.count = 2 {...}
Kyle KIM
  • 1,384
  • 2
  • 15
  • 31
  • The same was for me. This is a kind of usual typo mistakes everyone does. Compilator usually complains about it right away. However, if a variable is a little more complex, like an array of Tuples or something, the compilator simply goes crazy and can't point to this particular simple mistake showing "segmentation error" instead. – Vitalii May 25 '16 at 10:28
1

None of these answers worked for me but I found my issue. It had to do with Error Handling (in the Disabling Error Propagation section). I had this method:

func getSlider() throws -> UISlider {
  ... // code that could throw an error
  return UISlider()
}

Referencing it like this:

func anotherMethod() -> Float {
  return try! getSlider().value
}

gave the error. But, when switching to this, it went away:

func anotherMethod() -> Float {
  return (try! getSlider()).value
}
socom1880
  • 340
  • 3
  • 12
1

I also ran into this problem.... obviously, it is a general error or sorts... when the xcode gets confused.... in my case, I had 3 vars that I was assigning values to from an array.... but I did not specify the type of data in each element of the array.... once I did, it resolved the problem....

tj4shee
  • 371
  • 1
  • 2
  • 11
  • 1
    As nice as your answer could be for future visitors, this question is over a year old and with 30 answers already, so it's not likely many people will notice your answer. Also, I would like to politely point out that, although I understand what you're trying to say, answers are usually much more helpful to readers passing by when you use proper English grammar, so if you would like, feel free to edit your post to fix that part. The rest is awesome, though, and don't be discouraged! – Claudia May 20 '16 at 01:36
1

In my case I had declared the following property in one of my ViewControllers subclass:

@property NSString * title

I think this was conflicting with the already existing title property in ViewController. I renamed this property to something else and refactored its use and the error disappeared.

nmvictor
  • 1,109
  • 1
  • 15
  • 30
1

Human Error report:

In my case, the culprit was passing in an array in the place of a variadic parameter. That is, for the signature:

// Note the variadic parameter
func addSubview(subview subview: UIView, constrain: NSLayoutAttribute...)

I passed in:

// Compile-time error, "constrain" parameters have array brackets
someUIView.addSubview(subview: someOtherView, constrain: [.Leading, .Top, .Bottom, .Trailing])

rather than:

// Correct
someUIView.addSubview(subview: someOtherView, constrain: .Leading, .Top, .Bottom, .Trailing)
Community
  • 1
  • 1
AmitaiB
  • 1,656
  • 1
  • 19
  • 19
1

In my case it was caused by trying to use a function that returned an NSNumber as an argument where a Double was expected. My advice is be careful mixing Objective C objects with Swift datatypes. And as many others have suggested, comment out lines until you pinpoint which one causes the error. (Even if you create other errors when doing so, you can just ignore them and see what makes the segmentation fault error go away.)

Dan
  • 2,599
  • 1
  • 17
  • 13
1

For me I was blocking the main thread.

What I did to Fix it with GCD (see below)

dispatch_async(dispatch_get_main_queue(),      
})
Prune
  • 76,765
  • 14
  • 60
  • 81
1

I got segmentation fault on my Mac Mini using Xcode Bots. The seg fault did only occur during build step of testing and not during building or running locally. Only in Xcode bots during build step of testing.

I am using macOS Sierra and Xcode 8, with the code converted to Swift 2.3.

I finally found the line causing the seg fault, it was caused by:

public let isIpad = UIDevice.currentDevice().userInterfaceIdiom == .Pad

Which was declared outside a class as a constant. Changing it to check the userInterfaceIdiom at runtime fixed the issue.

Hopes this helps someone else!

This is the error log for my seg fault:

0  swift                    0x000000010f93d76b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x000000010f93ca56 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x000000010f93ddbf SignalHandler(int) + 287
3  libsystem_platform.dylib 0x00007fffb24aabba _sigtramp + 26
4  libsystem_platform.dylib 0x00007fbbfff49ae0 _sigtramp + 1302982464
5  swift                    0x000000010db79996 (anonymous namespace)::Traversal::visit(swift::Expr*) + 118
6  swift                    0x000000010db7b880 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 128
7  swift                    0x000000010db799eb (anonymous namespace)::Traversal::visit(swift::Expr*) + 203
8  swift                    0x000000010db78f45 swift::Expr::walk(swift::ASTWalker&) + 53
9  swift                    0x000000010d6d2c87 walkForProfiling(swift::AbstractFunctionDecl*, swift::ASTWalker&) + 231
10 swift                    0x000000010d6d2719 swift::Lowering::SILGenProfiling::assignRegionCounters(swift::AbstractFunctionDecl*) + 553
11 swift                    0x000000010d6de348 (anonymous namespace)::SILGenType::emitType() + 952
12 swift                    0x000000010d6ddf1e swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
13 swift                    0x000000010d6625eb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 731
14 swift                    0x000000010d663139 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 793
15 swift                    0x000000010d6635a3 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 115
16 swift                    0x000000010d491c18 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 12536
17 swift                    0x000000010d48dc79 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2777
18 swift                    0x000000010d489765 main + 1957
19 libdyld.dylib            0x00007fffb229e255 start + 1
Sajjon
  • 8,938
  • 5
  • 60
  • 94
1

When your development target is not supporting any UIControl

In my case i was using StackView in a project with development target 8.0. This error can happen if your development target is not supporting any UIControl.

When you set incorrect target

In below line if you leave default target "target" instead of self then Segmentation fault 11 occurs.

shareBtn.addTarget(self, action: #selector(ViewController.share(_:)), for: .touchUpInside)
Muhammad Adnan
  • 2,668
  • 15
  • 27
1

I had this line in my code

weakSelf?.notifications = weakSelf?.notifications ?? [] + weakSelf?.chatNotificationDataSource ?? []

this cause Segmentation fault. But then i changed it in this way:

weakSelf?.notifications = (weakSelf?.notifications ?? []) + (weakSelf?.chatNotificationDataSource ?? [])

and app started working.

Bohdan Savych
  • 3,310
  • 4
  • 28
  • 47
1

I also encounterd the Segmentation fault: 11 error because I was calling a method which was returning Any object and compiler got confused to understand the object type that was being used.

Casting Any object to the required type which I was using, solved my issue.

Rahul Kumar
  • 3,009
  • 2
  • 16
  • 22
1

If you're using multiple versions of XCode, this error can easily happen if your paths have changed (eg. You downloaded the DMG to Desktop, extracted, but then moved XCode to Applications afterward). Carefully read the Segmentation Fault 11 error given to you in XCode, it may reference your old path which is the cause of the Segmentation Fault. If it does, you can fix it by either:

  1. xcode-select the correct path. Eg. sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer/ (obviously input your correct path here)
  2. When installing your second version of XCode, ensure it's being extracted to the final path (extract to Applications itself) and that 'XCode.app' doesn't already exist when you do so (rename your previous one if it exists). After it's installed, you can rename both as you like.

Another potential fix for this issue:

Upgrading from El Capitan to Sierra and 'installing extra components' when launching Xcode after this upgrade fixed it for me the first time this happened.

Elliott Davies
  • 833
  • 9
  • 6
1

I tried to look for all the answers in my code, same repo was successfully built in other developer's PC. but not in mine :(

It took me almost a week to fix it. I did all possible combinations of checking like deleting derived data, closing xcode, restart pc, git stash, reset none of them help. Then I copied the build command which was failing in Xcode and ran it in terminal. It failed. showed one more line

(end of response file)
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)

Build command was more than 76K characters So I removed some parameters which are not mandatory and was able to proceed further in terminal.

So what I did to solve this problem is to take the repo from ~/Desktop/Work/PROJECT_NAME/repo/ssh/AAA to ~/Desktop/repo/ and problem solved

Long story short, take the repo close to ~/ so that path becomes less if you face this like me. My Xcode version 12.3

razibdeb
  • 1,211
  • 1
  • 10
  • 12
0

I actually screwed up Core Data entities a bit while porting from Swift 2.0 to 1.2 (don't ask why) I deleted all the entity classes and recreated them again. I got lots of error messages then and when I fixed them all the project built successfully.

Yaroslav
  • 2,435
  • 1
  • 19
  • 36
0

Just note for those who might be in the same situation as I was in, since this took me so much hours to resolve...

I encountered this error after I used Find/Replace functionality in Xcode. The problem is that some characters are "overreplaced" due to my carelessness (i.e. replace not only the relevant parts but also the redundant parts) and thus some of variables become undefined ones. Nonetheless those undefined variables weren't caught in the compile (even after making a clean) and finally the signal segmentation error was displayed on the screen.

Blaszard
  • 30,954
  • 51
  • 153
  • 233
0

There would be a filename mentioned after Command failed due to signal: Segmentation fault: 11 . Atleast in my case it was. With Swift upgrade to 2.0 some of the core properties were changes to optional. On not handling it appropriately it threw that error. Handling the optional well dismissed the error. In my case it was due to not handling :

        if let scheduledNotifications = UIApplication.sharedApplication().scheduledLocalNotifications as [UILocalNotification]?{
}  

Good Luck!

Ankish Jain
  • 11,305
  • 5
  • 36
  • 34
0

I ran into this while building for Tests. Build to Run works fine. Xcode 7/Swift 2 didn't like the way a variable was initialized. This code ran fine in Xcode 6.4. Here's the line that caused the seg fault:

var lineWidth: CGFloat = (UIScreen.mainScreen().scale == 1.0) ? 1.0 : 0.5

Changing it to this solved the problem:

var lineWidth: CGFloat {
    return (UIScreen.mainScreen().scale == 1.0) ? 1.0 : 0.5
}
Justin Vallely
  • 5,932
  • 3
  • 30
  • 44
0

Named tuples in array in a let property gave me the seg fault issue.

Justin Milo
  • 575
  • 4
  • 15
0

This happened to me when there were some nested functions in my code and one of the nested function was calling another nested function.

I just removed the chaining between the nested functions and this issue was fixed.

thanks to @Ron B's answer.

geekay
  • 1,655
  • 22
  • 31
0

I just had this issue and found that it was because I had accidentally left an override on a function that I'd moved from the class to a protocol (therefore the subclass was no longer overriding a function of the parent).

0

I encountered this bug when attempting to define a new OptionSetType struct in Swift 2. When I corrected the type on the init() parameter from Self.RawValue to Int the crash stopped occurring:

// bad:
//  public init(rawValue: Self.RawValue) {
//      self.rawValue = rawValue
//  }

// good:
public init(rawValue: Int) {
    self.rawValue = rawValue
}
devios1
  • 36,899
  • 45
  • 162
  • 260
0

In my case, I had several instances of methods taking a closure with a signature like this (notice the optional array of dictionaries):

// 'results' being nil means "failure".
func queryItems(
    completion:( (results:[[String:AnyObject]]?)->(Void) )
    )
{
   // (async operation...)

...which I started to refactor into:

// 'results' is NEVER nil (at most, empty). Pass any errors to the 
//   failure: closure instead.
func queryItems(
    success:( (results:[[String:AnyObject]])->(Void) ),
    failure:( (error:NSError) -> (Void) )
    )
{
   // (async operation...)

...but did not finish, so some methods expected a closure with an optional argument and where being passed a non-optional one (or viceversa?), and I guess the compiler lost track.

Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
0

For me this popped up when I accidentally called "super.init()" inside a completionHandler of a method that was called from the class init method.

init() {        
        someFunction(argument, completionHandler: { (data) -> () in
            super.init()
...
}

instead of

init() {    
        super.init()
        someFunction(argument, completionHandler: { (data) -> () in
        ...
}
zaltzy
  • 127
  • 5
0

In my case Product Clean and then restarting Xcode did resolve this problem...

Michal Gumny
  • 1,770
  • 1
  • 16
  • 24
0

I have experienced the same issue on my first try with Realm.io. The reason for the error was that I have named my target Realm and that caused namespace clashing. The issue was resolved after I have changed my project and target name into something else, as explained on this issue.

My suggestion is to check for similar namespace clashes.

Yunus Nedim Mehel
  • 12,089
  • 4
  • 50
  • 56
0

I got this error when getting a value from NSUserDefaults. The following gives error:

let arr = defaults.objectForKey("myArray")

What fixed the error was to cast the type to the correct type stored in NSUserDefaults. The following gives no error:

let arr = defaults.objectForKey("myArray") as! Array<String>
DevB2F
  • 4,674
  • 4
  • 36
  • 60
0

its a simple solution

Just Press cmd+shift+k

my problem is solved for clean the project

0

In my case, I was trying to extend a CoreData class with a helper method that could work on all of its subclasses:

extension ExampleCoreDataClass {
   static func insert() -> Self {
   ...

I got no warnings about this, but when I tried to compile it the segmentation fault appeared.

After struggling for a while I used a protocol extension instead and this resolved the error:

extension NSFetchRequestResult where Self: ExampleCoreDataClass {
   static func insert() -> Self {
   ...
Iree
  • 358
  • 3
  • 13
0

I got this error when I was trying to access a property of a singleton's struct instance from a 'static scope' within that singleton (that contains constants inside an enum that are never instantiated)

God Himself
  • 209
  • 1
  • 4
  • 15
0

In my case, I forgot to remove a 'colorLiteral' (which is not assigning to any property or not passing as a method parameter) in my source code that's why the compiler was not able to compile all swift files. I just removed the 'colorLiteral' and its working fine as expected.

0

For me, it was because of passing [String : Int] instead of [String : Any]check this image

Akash Neeli
  • 337
  • 4
  • 12
-1

In my case, IGListKit refactored their class named IGListSectionController to ListSectionController , while I already had a class named ListSectionController. I used find and replace and didn't know I had a class with the same name.

class ListSectionController : ListSectionController

I read the error message in full and concluded that this error can also happen when you have Circular dependencies. This wasn't mentioned in any of the comments, I hope this helps.

Grease
  • 1,308
  • 11
  • 12
-1

I had exactly the same issue, and after many hours of debugging, I found out it was because I was accessing a subscript by using .subscript() instead of between []. XCode thinks this is perfectly valid, but gives this segmentation fault error when building.

-1

Found this to happen when using ternary statements in a WKInterfaceController (ie Watch app)!

Chris Allinson
  • 1,837
  • 2
  • 26
  • 39
-1

I came across this error in a CI build and I couldn't reproduce it locally. Turns out I was using a different version of Xcode that what my CI was using.

Steve Moser
  • 7,647
  • 5
  • 55
  • 94