升级到Xcode 8后,我在下面的课程中遇到了分段11错误:
class WebServer: GCDWebServer
{
static let sharedInstance = WebServer()
var webServer = GCDWebServer()!
override init()
{
GCDWebServer.setLogLevel(5) // comment out line for debug purposes
self.webServer.addGETHandler(forBasePath: "/", directoryPath: "/", indexFilename: "", cacheAge: 0, allowRangeRequests: true)
self.webServer.start(withPort: 8080, bonjourName: "GCD Web Server")
}
func getURLForPage(_ pageName:String)->URL
{
let fileUrl = Bundle.main.url(forResource: pageName, withExtension: "html")
let filePath = String(validatingUTF8: fileUrl!.path)!
let webURLStr = "http://127.0.0.1:8080" + filePath
return URL(string: webURLStr)!
}
}
日志指向init但是通过注释项目我可以看到它与使用Objective C类GCDWebServer有关。具体的日志错误是:
While emitting IR SIL function @_TFC4Book9WebServercfT_S0_ for 'init' at
然后指向上面的init方法。在升级到Xcode 8之前,所有这些工作都很好。
感谢。