所以我一直把头发拉过这个神秘的问题(至少对我而言).它只发生在App Store上.我尽力检查我的BookingViewModel代码,我确信那里应该没有崩溃,所以我做了一些清理,然后上传了一个新版本到TestFlight,并再次发生崩溃.
这是Fabric's Crashlytics的崩溃日志的屏幕截图:
和一段堆栈跟踪:
#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)
Run Code Online (Sandbox Code Playgroud)
最后,来自我的代码BookingViewModel有崩溃日志中描述的第167行(我已经编辑了这个问题的代码,我删除了一些行,但是这个想法仍然存在,也是为了使代码简短):
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
)
}
Run Code Online (Sandbox Code Playgroud)
所以问题是:是否存在关于应用程序从App Store或Testlfight下载时如何崩溃的现有想法,而不是在开发/调试模式(在Xcode中运行)时?
此外,是否有可能在App Store上模拟项目的状态(例如,我已经阅读了某人的答案,我可以将项目的代码签名更改为iOS Distribution)?
谢谢!
好吧,如果有人被此类问题困扰,将导致奇怪崩溃的行放在主线程中会有所帮助!
我不确定为什么,也许我应该更多地检查代码。再说一遍,我只需将崩溃的行放入主线程中,如下所示:
DispatchQueue.main.async {
self.bookingViewModel = BookingViewModel(self.booking, withCompleteInfoCompletion: {
....
})
}
Run Code Online (Sandbox Code Playgroud)
Larme 的上述评论对我帮助很大!
| 归档时间: |
|
| 查看次数: |
985 次 |
| 最近记录: |