Xcode/Swift 错误:由于信号导致命令失败:分段错误:11 [英] Xcode/Swift error: Command failed due to signal: Segmentation fault: 11

查看:38
本文介绍了Xcode/Swift 错误:由于信号导致命令失败:分段错误:11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用完成处理程序参数调用单例类的函数,但出现由于信号导致命令失败:分段错误:11"错误.我正在使用 Xcode 6.2 (6C101) 并尝试在 iPhone 6 模拟器上为 iOS 8 构建.这是单顿类:

I am trying to call a function of a singleton class with completion handler argument but I get "Command failed due to signal: Segmentation fault: 11" error. I am using Xcode 6.2 (6C101) and trying to build for iOS 8 on iPhone 6 simulator. Here is the singlton class:

public class ClientManager {

    public class var sharedInstance: ClientManager {
        struct Singleton {
            static let instance = ClientManager()
        }
        return Singleton.instance
    }

    private init() {
    }

    public func fetchServiceInfo(serviceName: String, completionHandler: (JSON?, NSError?) -> Void) {
        Alamofire.request(.GET, Router.ServiceInfo(serviceName)).responseJSON { (req, res, json, error) in
            completionHandler(JSON(json!), error)
        }
    }

}

当我在视图控制器中调用 fetchServiceInfo 函数时,Xcode 崩溃(SourceKitService Crashed):

And when I call fetchServiceInfo function within a view controller, Xcode crashes (SourceKitService Crashed):

ClientManager.sharedInstance.fetchServiceInfo("default") { (json, error) in
    println(json)
}

但是,如果我在 ClientManagerinit 方法中调用相同的函数,它可以正常工作:

However, if I call the same function within the init method of ClientManager it works properly:

private init() {
    self.fetchServiceInfo("default") { (json, error) in
        println(json)
    }
}

我正在使用 AlamofireSwiftyJSON 库.

I am using Alamofire and SwiftyJSON libraries.

推荐答案

¿您是否有可能使用 SwiftyJSON 作为框架、cocoapods 或 git 子模块?查看 https://github.com/SwiftyJSON/SwiftyJSON/issues/125在您的项目中使用 SwiftyJSON.swift 文件必须工作正常

¿Is posible you are using SwiftyJSON as framework, cocoapods or git submodule? Look at https://github.com/SwiftyJSON/SwiftyJSON/issues/125 Using SwiftyJSON.swift file into your project must work fine

这篇关于Xcode/Swift 错误:由于信号导致命令失败:分段错误:11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆