Swift崩溃Crashlytics 0x0000000104fbdf84

Crashlytics显示我的应用程序在第238行崩溃,实际上这个问题发生了一段时间。我尝试在模拟器和测试电话上模拟此问题,但没有崩溃。

我尝试在phoneNo变量上添加验证,并更改用于更改标签文本的函数。但是崩溃仍然在发生。

Crashlytics

Crashlytics issue details

override func viewDidLoad() {
    super.viewDidLoad()
    if #available(iOS 12.0,*) {
        verifyCodeTF.textContentType = .oneTimeCode
    } 
    hideKeyboard()

    eventLogger(eventKey: FirebaseKeyConstructor.getPhoneNumberVerificationKey(),eventType: viewOpenedEvent)
    phoneValidation()

    print(labelPhoneNo)
    if let phoneNo = labelPhoneNo {
/*line 238 here*/resendLabel.text = String.localizedStringWithFormat(LocalizedString.getResentLabelStr(),phoneNo) 
        //resendLabel.text = String(format: LocalizedString.getResentLabelStr(),phoneNo)
    }
    resend()
    addDefaultBackground()

}

电话验证功能如下:

func phoneValidation() {
    let country = defaults.string(forKey: countryKey)
    let phoneNo = defaults.string(forKey: userPhoneKey)
    if country != nil && phoneNo != nil {
        switch country {
        case malaysiaCountry:
            if (phoneNo?.hasPrefix("0"))! {
                formattedPhoneNo = "+6" + phoneNo!
            } else if (phoneNo?.hasPrefix("1"))! {
                formattedPhoneNo = "+60" + phoneNo!
            } else if (phoneNo?.hasPrefix("6"))! {
                formattedPhoneNo = "+" + phoneNo!
            } else {
                formattedPhoneNo = phoneNo
            }
        case singaporeCountry:
            if (phoneNo?.hasPrefix("65"))! {
                formattedPhoneNo = "+" + phoneNo!
            } else if phoneNo?.hasPrefix("+65") == false {
                formattedPhoneNo = "+65" + phoneNo!
            } else {
                formattedPhoneNo = phoneNo
            }
        case indonesiaCountry:
            if (phoneNo?.hasPrefix("62"))! {
                formattedPhoneNo = "+" + phoneNo!
            } else if phoneNo?.hasPrefix("+62") == false {
                formattedPhoneNo = "+62" + phoneNo!
            } else {
                formattedPhoneNo = phoneNo
            }
        case thailandCountry:
            if (phoneNo?.hasPrefix("66"))! {
                formattedPhoneNo = "+" + phoneNo!
            } else if phoneNo?.hasPrefix("+66") == false {
                formattedPhoneNo = "+66" + phoneNo!
            } else {
                formattedPhoneNo = phoneNo
            }
        default:
            formattedPhoneNo = phoneNo
        }
        labelPhoneNo = formattedPhoneNo
        labelPhoneNo.insert(" ",at: labelPhoneNo.index(labelPhoneNo.startIndex,offsetBy: 3))
    } else {
        performStopAlert(title: AlertMessages.getErrorMsg(),message: "Country or phone number is empty,please try again...")
    }

}

LocalizedString.getResentLabelStr()值:

static private let resendLabel      : String = NSLocalizedString("Resend_Label",comment: "")

static func getResentLabelStr() -> String {
    return resendLabel
}

用于英语,泰语的LocalizedString(印度尼西亚也使用英语语言环境)

English : "Resend_Label" = "Your SMS code will arrive in 2 minutes to phone number %@. If you have not received it,please click on the Resend button below."
Thai : "Resend_Label" = "คุณจะได้รับรหัส SMS ภายใน 2 นาที ไปยังหมายเลขโทรศัพท์ %@. หากยังไม่ได้รับกรุณาคลิกที่ปุ่มด้านล่างอีกครั้ง";
xiaolongxiadoudou 回答:Swift崩溃Crashlytics 0x0000000104fbdf84

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3160845.html

大家都在问