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

前端 未结 25 2159
耶瑟儿~
耶瑟儿~ 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:20

    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

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

    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.

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

    I had the same error because of:

     let stringB: String? = stringA.characters.count = 0 ? nil : stringA
    

    Solution was to change it to:

     let stringB: String? = stringA.characters.count > 0 ? stringA : nil
    

    Maybe this helps someone...

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

    I faced this compilation error in Xcode Version 7.3 (7D175), swift project. The following is the scenario:

    1. Declared "@objc protocol" in swift class
    2. In another class that implements this protocol, one of the non-optional methods is not implemented

    Implementing the method solved the problem for me. This might be one of the reasons for people facing this problem. I hope that this helps

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

    For me:

    I use Closure as AnyObject, after I use this Cast closures/blocks function. Error solved.

    typealias UserCallBack = () -> Void
    ...
    if let callBack = callBack as? AnyObject {
      request?.userInfo["callBack"] = callBack
    }
    
    0 讨论(0)
  • 2020-12-01 06:21

    I have a project that it happens in the same file from time to time. My workaround is :

    Go to the file that the segmentation fault mentioned, comment out all imports, run (Build fails obviously), uncomment all imports -> Builds successfully.

    My imports were Firebase and FirebaseAuth if it helps anyone.

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

    For me it was a lengthy function that contained test data array.

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