所以我一直在为这个神秘的问题发愁(至少对我来说)。它只在应用商店发生。我尽力检查了我的
bookingViewModel
codes,我确信那里应该没有崩溃,所以我做了一些清理,然后上传了一个新的构建到testfirght,崩溃再次发生。
以下是Fabric's Crashlytics的撞车日志截图:
一块StackTrace:
0.崩溃:com.apple.main-thread
0 libswiftcore.dylib 0x103e70314 swift_UnknownRelease+24
1个libswiftcore.dylib 0X103E37B5C swift-arraydestory+68
2 libswiftcore.dylib 0x103C308C0(丢失)
3 libswiftcore.dylib 0X103E40F04 Swift_UnownedCheck+88
4 AppName 0x102940848 BookingViewModelBookingViewModelBooking第一个元素标记空列表字符串(BookingViewModel.Swift:167)
最后,我的bookingViewModel的代码具有crashlog中描述的行167(我已经为这个问题编辑了代码,我删除了一些行,但想法仍然存在,也使代码变短):。
init(booking:booking,withcompleteinfo completeinfo:@escaping bookingviewmodelcompleteinfo completion){
让createddate=booking.createdate?“?”
让username=booking.username?“?”
让firstname=booking.firstname?“?”
让lastname=booking.lastname?“?”
让年龄=预订年龄?“?”
让birthdate=booking.birthdate?“?”
//完成的最终值
让userdetails=“(firstname)\(firstname)\(age)/\(birthdate)”。压缩显示空间
//预订状态和总金额
var bookingstatus:bookingstatus=。用于处理
如果let status=booking.status,
让statussid=status.id,
让newbookingstatus=bookingstatus(rawvalue:statusid){
bookingStatus=新预订状态
}
VaR总金额:双倍=0.00
如果bookingstatus==.forPayment bookingstatus==.paid bookingstatus==.forconfirmation{
如果let amount=booking.amount{
金额{
如果让amountString=amount.amount,
让amountdouble=double(amountstring){
合计金额=合计金额+金额加倍
}
}
}
}
self.subtotal=string(格式:“%.2f”,参数:[totalAmount])
//付款方式
var paymenttype:paymenttype=.cod
如果let paymentmethod=booking.paymentmethod,
let type=paymenttype(rawvalue:paymentmethod){
paymentType=类型
}
//初始合计
让NealAlgOn= =“Ay±\(So.GutoToalSalm(.Paypal)””
完整信息(
“_塯±\(self.subtotal)”,//第167行
用户详细信息
)
}
所以问题是:有没有一个现有的想法,当一个应用程序从应用程序商店或testlfight下载,而不是在开发/调试模式(在xcode中运行)时,它是如何崩溃的?
此外,是否可以在应用程序商店中模拟项目的状态(例如,我在上阅读了某人的答案,以便将项目的代码签名更改为ios distribution)?
谢谢!代码,我确信那里不应该有崩溃,所以我做了一些清理,然后上传了一个新的构建到TestFlight,崩溃再次发生。
以下是Fabric's Crashlytics的碰撞日志截图:
还有一块StackTrace:
#0. Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x103e70314 swift_unknownRelease + 24
1 libswiftCore.dylib 0x103e37b5c swift_arrayDestroy + 68
2 libswiftCore.dylib 0x103c308c0 (Missing)
3 libswiftCore.dylib 0x103e40f04 swift_unownedCheck + 88
4 appname 0x102940848 BookingViewModelBookingViewModelBooking first-element-marker empty-list String (BookingViewModel.swift:167)
最后,我的代码预订视图模型
有第167行在crashlog中描述(我已经为这个问题编辑了代码,删除了一些行,但这个想法仍然存在,也使代码简短):
init(_ booking: Booking, withCompleteInfoCompletion completeInfo: @escaping BookingViewModelCompleteInfoCompletion) {
let createdDate = booking.createdAt ?? ""
let username = booking.username ?? ""
let firstName = booking.firstName ?? ""
let lastName = booking.lastName ?? ""
let age = booking.age ?? ""
let birthdate = booking.birthdate ?? ""
// Final values for completion
let userDetails = "\(firstName) \(lastName) \(age) / \(birthdate)".condensedWhitespace
// Booking Status and total amount
var bookingStatus: BookingStatus = .forProcessing
if let status = booking.status,
let statusId = status.id,
let newBookingStatus = BookingStatus(rawValue: statusId) {
bookingStatus = newBookingStatus
}
var totalAmount: Double = 0.00
if bookingStatus == .forPayment || bookingStatus == .paid || bookingStatus == .forConfirmation {
if let amounts = booking.amount {
for amount in amounts {
if let amountString = amount.amount,
let amountDouble = Double(amountString) {
totalAmount = totalAmount + amountDouble
}
}
}
}
self.subtotal = String(format: "%.2f", arguments: [totalAmount])
// Payment Method
var paymentType: PaymentType = .cod
if let paymentMethod = booking.paymentMethod,
let type = PaymentType(rawValue: paymentMethod) {
paymentType = type
}
// Initial Total
let initialTotal = "â±\(self.getTotalAmount(.paypal))"
completeInfo(
"â±\(self.subtotal)", // line 167
userDetails
)
}
所以问题是:有没有一个现有的想法,当一个应用程序从应用程序商店或testlfight下载,而不是在开发/调试模式(在xcode中运行)时,它是如何崩溃的?
此外,是否可以在应用程序商店中模拟项目的状态(例如,我已经阅读了某人的答案,以便将项目的代码签名更改为iOS Distribution
)?
谢谢您!