命令因信号:段错误:11而失败

158

当尝试编译我的Swift应用程序时,我遇到了错误...

由于信号:Segmentation fault: 11,命令失败

我正在使用Xcode 6.1,尝试为运行在iOS 8.1上的iPhone 5构建。

我的代码

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.
    }
}

还有错误文本!

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")
            }
        }"

显示错误的代码和您发布的代码不同。您的代码是用于登录的,而错误代码是注册方法。您是否设置了闭包中断点以尝试识别问题? - Paulw11
你不需要猜测。在项目所在的终端中键入 xcodebuild -verbose,并查看错误的具体位置和原因。 - oyalhi
57个回答

1
在我的情况下,我在我的一个视图控制器子类中声明了以下属性:
@property NSString * title

我认为这与已经存在于ViewController中的title属性发生了冲突。我将此属性重命名为其他名称,并重构了其使用,错误消失了。


1
在我的情况下,原因是在扩展中的另一个类中声明了一个类。
extension classOrig {
    class classChild {
        class classGrandChild {
            static let aVariable : String = "SomeValue";
        }
    }
}

这在我的项目中引起了错误。我有几个框架,但之前并没有发生过这种情况。

1

在尝试构建发布方案时,我遇到了代码11的问题。它指出一个视图控制器类(Swift)内部有以下代码:

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

问题在于当我将超类添加到其中时,我忘记了实现init。因此,super.init导致编译器错误分段错误:11 因此,如果您遇到这样的问题,最好也检查任何超类。

1
我在代码中有这一行:

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

这会导致分段错误。 但是我按照以下方式进行了更改:

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

应用程序已开始运作。


1
我也遇到了 Segmentation Fault 11 错误,当我导入我自己制作的框架时(是的,感觉自己非常愚蠢)。
开发了几个月的框架,将其与混合使用 Obj-C 和 Swift 的主项目集成后,在 Obj-C 中导入没有问题,但一旦我在 Swift 中写入"import MySwiftProject",所有的问题就都暴露出来了。
长话短说,问题是我创建了一些自定义方法,使用闭包提供了对 "NSNotifications" 的类型化支持,例如:
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)
        }
    }
}

实际上,我使用了一个模板来编写上面的代码,但这是另外一个故事。

主要的罪魁祸首?就是这个:

func ... -> NSObjectProtocol

显然,苹果可以在声明NSNotification的方法中使用NSObjectProtocol,但是当我这样做时,会出现Segfault 11。将NSObjectProtocol替换为AnyObject解决了崩溃问题。不幸的是,这可能无法解决你的问题,因为segfault 11只是编译器的一般性崩溃,但你可以采取措施来解决它。我花了大约2个小时,以下是我所做的事情:1.创建一个新项目,复制原有结构。在我的情况下,我创建了一个单视图控制器Swift项目,并在其中添加了一个Swift框架作为另一个项目。2.将所有原始代码从一个项目复制到另一个项目。3.进入编译阶段,开始删除要编译的文件,尝试禁用非常Swift-hacky的代码(例如我的NSNotification类型化)。4.每次进行更改时,都要进行清理(⌘+⌥+ ⇧+K),构建(⌘+B)并修复任何错误。5.从第3步重复,直到分段错误消失。

0
在我的情况下,我有几个方法实例需要带有以下签名的闭包(请注意可选字典数组):
// 'results' being nil means "failure".
func queryItems(
    completion:( (results:[[String:AnyObject]]?)->(Void) )
    )
{
   // (async operation...)

...我开始重构成:

// '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...)

...但没有完成,因此一些方法期望一个带可选参数的闭包,而被传递了一个非可选的参数(或者反过来?),我猜编译器失去了追踪。


0
在我的情况下,我试图通过一个帮助方法来扩展一个CoreData类,以便它可以在所有子类上工作:
extension ExampleCoreDataClass {
   static func insert() -> Self {
   ...

我没有收到任何关于这个的警告,但是当我尝试编译它时,出现了分段错误。

经过一番努力,我使用了协议扩展来解决这个错误:

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

0

在“Command failed due to signal: Segmentation fault: 11”之后会提到一个文件名。至少在我的情况下是这样的。随着Swift升级到2.0,一些核心属性被更改为可选项。如果没有适当处理它,就会抛出该错误。良好处理可选项可以消除错误。在我的情况下,是由于没有处理好可选项导致了这个错误。

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

祝你好运!


0
对我来说,当我在一个被从类的初始化方法调用的方法的completionHandler中意外地调用了"super.init()"时,这个问题就出现了。
init() {        
        someFunction(argument, completionHandler: { (data) -> () in
            super.init()
...
}

而不是

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

0
在尝试在 Swift 2 中定义新的 OptionSetType 结构体时,我遇到了这个 bug。当我将 init() 参数上的类型从 Self.RawValue 更正为 Int 后,崩溃就停止发生了。
// bad:
//  public init(rawValue: Self.RawValue) {
//      self.rawValue = rawValue
//  }

// good:
public init(rawValue: Int) {
    self.rawValue = rawValue
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接