错误-细分错误:Xcode 10中为11

时间:2018-10-03 07:40:24

标签: ios swift crash xcode10

我在Xcode 9中工作。代码工作正常,但是当我在Xcode 10中使用相同的代码时,我会遇到编译时错误。

这是错误:

1.  While emitting SIL for 'fetchConsumerRecommendations(completionHandler:failureHandler:)' at /Users/shahezad/Desktop/Newcode/foodkonnectconsumer-ios/Food/FirebaseManager.swift:2578:5
2.  While silgen emitFunction SIL function "@$S4Food15FirebaseManagerC28fetchConsumerRecommendations17completionHandler07failureH0yySaySSGc_ys5Error_pSgctFZ".
 for 'fetchConsumerRecommendations(completionHandler:failureHandler:)' at /Users/shahezad/Desktop/Newcode/foodkonnectconsumer-ios/Food/FirebaseManager.swift:2578:5
3.  While silgen closureexpr SIL function "@$S4Food15FirebaseManagerC28fetchConsumerRecommendations17completionHandler07failureH0yySaySSGc_ys5Error_pSgctFZySo19FIRDocumentSnapshotCSg_AItcfU_".
 for expression at [/Users/shahezad/Desktop/Newcode/foodkonnectconsumer-ios/Food/FirebaseManager.swift:2584:285 - line:2615:9] RangeText="{ (documentSnapshot, error) in


            if error == nil {

                if (documentSnapshot?.exists)!{

                    print("Consumer Recommendations - \(describing: documentSnapshot?.data())")

                    let dictOnboarding:NSDictionary = (documentSnapshot?.data())! as NSDictionary

                    print("\(dictOnboarding.allKeys)")

                    completionHandler(dictOnboarding.allKeys as! [String])

                }
                else{


                    completionHandler([])

                }

            }
            else{

                failureHandler(error)

            }


        }"
error: Segmentation fault: 11

我无法弄清楚代码的问题所在。

2 个答案:

答案 0 :(得分:0)

此问题背后可能有两个原因。应用程序中的其中一个Pod可能正在使用CommonCrypto,或者Swift语言版本可能不明确。对于这两个问题,都有以下解决方案:

方法1

  1. 在整个项目中搜索CommonCrypto一词。
  2. 如果您具有包含该标头导入的Pod,请从Podfile中删除此Pod并执行Pod安装。
  3. 清理并构建项目。
  4. 再次将Pod添加到Podfile并执行Pod安装。
  5. 如果可能,请使用真实设备清洁并重新构建项目。

如果没有该Pod,也许您可​​以尝试使用与项目中可能遇到的一些旧Pod相同的步骤。

添加的信息:另外,如果Pod内发生代码错误,则首先需要解决该代码问题,然后尝试再次编译项目。

方法2

请确保您的项目Swift语言版本是正确的版本。对于Xcode 10,我建议您使用Swift 4.2,也可以选择当前编写代码的版本。 Your can follow your Build Settings in your target as in the this image

我希望这会有所帮助

致谢

答案 1 :(得分:0)

也许将来有人会在解析json排序时犯我的错误,如下所示:

let countryList = try? JSONDecoder().decode([Country].self, from: data)
   if let countryList = countryList {
         completion(countryList.sorted(by: <))
   }