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

30,993

Solution 1

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!

Solution 2

This indicates that some Required method/func is missing from your code. In my case I was using ObjectMapper and in my class I was forgot to include required init() method which causes this "Command failed due to signal: Segmentation fault: 11"

required init?(_ map: Map) {

}

Solution 3

Look at the other warning you see around.

My case pointed me to problem with iOS9 and GoogleAds. See here: https://developers.google.com/admob/ios/ios9

Short answer was to disable build setting ENABLE_BITCODE.

My error:

ld: '/pp/src/shared_js/libs/GoogleMobileAdsSdkiOS-7.3.1/GoogleMobileAds.framework/GoogleMobileAds(GADGestureIdUtil.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)

Solution 4

I have face this problem many time while converting various projects to Swift3.0.

As this issue looks dynamic, every one has its own solution other then any universal answer. But in this issue main problem is to identify spot to get work on. So What I am following is as below:

  • Identify method which one is responsible for error

    Click on Error Message

enter image description here

  • Here you will identify class which responsible for error to generate compile time error

    enter image description here

In my case AppDelegate is responsible.

  • To find line of error, go to end of long error description.You will find code something like below:

    1. While emitting IR SIL function @_TFC9MyProject11AppDelegate21getNotificationDetailfGSqGVs10DictionaryVs11AnyHashableP___T_ for 'getNotificationDetail' at /Users/ABC/Documents/BitBucket/iOS/2016/Projects/MyProject/AppDelegate/AppDelegate.swift:153:5

Here 153 is line of code in AppDelegate.swift.

func getNotificationDetail(_ launchOptions : [AnyHashable: Any]?) {
    if launchOptions != nil {
        let dictLaunch = launchOptions! as NSDictionary
        NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.openRespectiveNotificationScreen), name: NSNotification.Name(rawValue: WebServiceKey.APPMANAGER_SERVICE_CALL_FINISH), object: nil)

        inactiveUserInfo  = dictLaunch.object(forKey: UIApplicationLaunchOptionsKey.remoteNotification) as? NSDictionary
    }
}

Then comment all the code inside method and build again. Then try uncomment one by one line ,so you finally get line which generates error.

After finding exact line of code, you can easily fix it.

In my code i find last line of this method generate error.

So i replace it with below code and it build get successfully.

inactiveUserInfo  = dictLaunch[UIApplicationLaunchOptionsKey.remoteNotification] as? NSDictionary

So main thing is to debug cautiously. Try this way, you will definitely solve error easily.

Solution 5

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^)/

Share:
30,993
Chirila Vasile
Author by

Chirila Vasile

Updated on July 28, 2022

Comments

  • Chirila Vasile
    Chirila Vasile over 1 year

    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 code (or something like this). Okay, I accepted and after this appeared "Command failed due to signal: Segmentation fault: 11" compile error (if you want details about this, I can write the whole error text). Anyone have the same issue?

    Thanks

    Edited

    I installed back Xcode 6.4 and it's okay, no compilation errors.