Xcode 7 compile error : “Command failed due to signal: Segmentation fault: 11”

前端 未结 25 2158
耶瑟儿~
耶瑟儿~ 2020-12-01 05:37

Yesterday I installed the official Xcode 7 and when I tried to open one of my Swift projects, appeared an alert saying that the new Xcode version wants to update my swift co

相关标签:
25条回答
  • 2020-12-01 06:07

    Omg, this is a terrific bug of Xcode. Just read this. http://blog.bellebethcooper.com/xcode-bug.html It made me smile.

    The change was deceptively small, but here's what it was (inside my API client class, where I actually get the JSON data from the API):

    I changed this:

    `let json = try? NSJSONSerialization.JSONObjectWithData(data, options: [])`
    

    to this:

    `let json = try? NSJSONSerialization.JSONObjectWithData(data, options: []) as! [String: AnyObject]`
    

    This is one of the most frustrating debugging experiences I've ever had, but I hope this post might help someone else who has the same issue. And if you ended up here via googling a bug you're struggling with and this didn't help you, I'm so sorry. I know exactly what you're going through. Don't give up!

    0 讨论(0)
  • 2020-12-01 06:09

    I was trying to make use of ?? in a clever way when this happened to me.

    I guess swift does not like when you try to chain multiple ?? together as in, though the syntax highlighter doesn't throw any error:

    let ageNum = self.ageValue > 0 ?? self.birthday?.ageFromDate() ?? 0
    
    0 讨论(0)
  • 2020-12-01 06:10

    Read the debug message carefully.

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

    if aString.characters.count = 2 {...}
    
    0 讨论(0)
  • 2020-12-01 06:10

    I had the same error in my project after upgrading to xCode 7. I decided to remove the new version of xCode and install xCode 6.4. After all, it worked fine using xCode 6.4, so i suggest you do that to start with. On other hands, you should always be up to date, but you can also have both xCode 6.4 and 7.0 :) Hope this works out for you!

    0 讨论(0)
  • 2020-12-01 06:13

    I had the same problem. Xcode 7.2.1. And selecting the error and expanding the logs I could find the compile error buried among the long paths.

    See the line after the "1." in the attached image. It has a reference to a file and a line. Looking at it I could find the error.

    In my case, I had an invalid enumeration assignment, I moved some logic from a struct to an enumeration and injected this error:

    I had:

    return .Success(dict: dict)
    

    I should have:

    return .Success(dict)
    

    0 讨论(0)
  • 2020-12-01 06:14

    At first, I recommend to watch the build log carefully to find the file having problems. In my case, an optional value used in for loop caused Segmentation fault on the build process.

    for i in 0..<hoge?.count {
    

    I fixed my code like following;

    for i in 0..<hoge!.count {
    

    I have no error now. \(^o^)/

    0 讨论(0)
提交回复
热议问题