swift – App works fine on device and simulator, but Apple review sends me this crash log

Here is the crash log Apple Review sent me. I’ve never had this issue previously, and it seems like the issue is coming from old code I’ve had no problem with before. I tried uninstalling and reinstalling Firebase firestore, storage, analytics, AdSupport, Auth, and kingfisher with Swift Package Manager with no success, and I can’t replicate the error on my device, the simulator, or testflight. Any help deciphering the crash log is much appreciated. I’m new to deciphering crash logs as I’ve never had an issue like this before so any help or direction on this is helpful.


Incident Identifier: B59F06E2-AEE1-481D-8B7C-E13EA1EBB3A5
CrashReporter Key:   4808b991e8d5157f0ce4498edd01aa490f760f0d
Hardware Model:      iPad11,6
Process:             uEats [42025]
Path:                /private/var/containers/Bundle/Application/7C7686D2-1729-4FCA-8CFB-B5D3FC5540D3/uEats.app/uEats
Identifier:          io.siub.uEats
Version:             3.5 (5)
AppStoreTools:       13E500
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           io.siub.uEats [4847]

Date/Time:           2022-05-06 07:56:38.9859 +0100
Launch Time:         2022-05-06 07:56:37.1542 +0100
OS Version:          iPhone OS 15.4.1 (19E258)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000104f8bdec
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [42025]

Triggered by Thread:  0

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   uEats                                  0x104f8bdec specialized RestaurantManager.openOrClosed(restaurant:) + 310764 (RestaurantManager.swift:200)
1   uEats                                  0x104f8b4b8 specialized RestaurantManager.openOrClosed(restaurant:) + 308408 (RestaurantManager.swift:200)
2   uEats                                  0x104f8a830 RestaurantManager.sortOpen() + 305200 (RestaurantManager.swift:154)
3   uEats                                  0x104f887c4 closure #1 in RestaurantManager.grabRestaurantData() + 296900 (RestaurantManager.swift:0)
4   uEats                                  0x104fb40dc thunk for @escaping @callee_guaranteed (@guaranteed FIRQuerySnapshot?, @guaranteed Error?) -> () + 475356 (<compiler-generated>:0)
5   uEats                                  0x105320d2c -[FIRQuery wrapQuerySnapshotBlock:]::Converter::OnEvent(firebase::firestore::util::StatusOr<firebase::firestore::api::QuerySnapshot>) + 4066604 (FIRQuery.mm:0)
6   uEats                                  0x105335878 firebase::firestore::api::Query::GetDocuments(firebase::firestore::api::Source, std::__1::unique_ptr<firebase::firestore::core::EventListener<firebase::firestore::api::QuerySnapshot>, std::__1::default_delete<firebase::firestore::core::EventListener<firebase::firestore::api::QuerySnapshot> > >&&)::ListenOnce::OnEvent(firebase::firestore::util::StatusOr<firebase::firestore::api::QuerySnapshot>) + 4151416 (query_core.cc:159)
7   uEats                                  0x105335ee0 firebase::firestore::api::Query::AddSnapshotListener(firebase::firestore::core::ListenOptions, std::__1::unique_ptr<firebase::firestore::core::EventListener<firebase::firestore::api::QuerySnapshot>, std::__1::default_delete<firebase::firestore::core::EventListener<firebase::firestore::api::QuerySnapshot> > >&&)::Converter::OnEvent(firebase::firestore::util::StatusOr<firebase::firestore::core::ViewSnapshot>) + 4153056 (query_core.cc:208)
8   uEats                                  0x105320b74 void std::__1::__invoke_void_return_wrapper<void, true>::__call<firebase::firestore::core::AsyncEventListener<firebase::firestore::core::ViewSnapshot>::OnEvent(firebase::firestore::util::StatusOr<firebase::firestore::core::ViewSnapshot>)::'lambda'()&>(firebase::firestore::core::AsyncEventListener<firebase::firestore::core::ViewSnapshot>::OnEvent(firebase::firestore::util::StatusOr<firebase::firestore::core::ViewSnapshot>)::'lambda'()&) + 4066164 (invoke.h:61)
9   uEats                                  0x105423f34 firebase::firestore::util::Task::ExecuteAndRelease() + 5127988 (task.cc:107)
10  libdispatch.dylib                      0x180d89a2c _dispatch_client_callout + 20
11  libdispatch.dylib                      0x180d97f48 _dispatch_main_queue_drain + 928
12  libdispatch.dylib                      0x180d97b98 _dispatch_main_queue_callback_4CF + 44
13  CoreFoundation                         0x1810db2f0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
14  CoreFoundation                         0x1810951f4 __CFRunLoopRun + 2532
15  CoreFoundation                         0x1810a86b8 CFRunLoopRunSpecific + 600
16  GraphicsServices                       0x19d142374 GSEventRunModal + 164
17  UIKitCore                              0x183a0de88 -[UIApplication _run] + 1100
18  UIKitCore                              0x18378f5ec UIApplicationMain + 364
19  SwiftUI                                0x188edf640 closure #1 in KitRendererCommon(_:) + 164
20  SwiftUI                                0x188e0d524 runApp<A>(_:) + 252
21  SwiftUI                                0x188dee810 static App.main() + 128
22  uEats                                  0x104f47f90 main + 32656 (ServerManager.swift:0)
23  dyld                                   0x105acdce4 start + 520

Thread 1 name:   Dispatch queue: com.google.fira.worker
Thread 1:
0   libsystem_kernel.dylib                 0x1b7e68bdc kevent_id + 8
1   libdispatch.dylib                      0x180dac1fc _dispatch_kq_poll + 228
2   libdispatch.dylib                      0x180dacf5c _dispatch_event_loop_end_ownership + 356
3   libdispatch.dylib                      0x180d99044 _dispatch_sync_complete_recurse + 88
4   libdispatch.dylib                      0x180d990d0 _dispatch_sync_invoke_and_complete_recurse + 88
5   libdispatch.dylib                      0x180d98b44 _dispatch_sync_f_slow + 172
6   uEats                                  0x10502c4c0 -[GULMutableDictionary objectForKeyedSubscript:] + 967872 (GULMutableDictionary.m:84)
7   uEats                                  0x1055d503c -[APMRemoteConfig numberFromCacheWithKey:defaultValue:maxValue:minValue:block:] + 148
8   uEats                                  0x1055d5480 -[APMRemoteConfig intValueFromCacheWithKey:defaultValue:maxValue:minValue:] + 188
9   uEats                                  0x10556e680 APMNormalizedParametersForParametersAndEventName + 1864
10  uEats                                  0x1055699e0 -[APMEvent initWithOrigin:isPublic:name:timestamp:previousTimestamp:parameters:] + 424
11  uEats                                  0x105583f28 -[APMMeasurement logEventOnWorkerQueueWithOrigin:isPublicEvent:name:parameters:timestamp:enabled:ignoreEnabled:ignoreInterceptor:interceptor:addedScreenParameters:] + 240
12  uEats                                  0x105583d90 __151-[APMMeasurement logEventWithOrigin:isPublicEvent:name:parameters:timestamp:enabled:ignoreEnabled:ignoreInterceptor:interceptor:addedScreenParameters:]_block_invoke + 68
13  uEats                                  0x1055d5a80 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 44
14  libdispatch.dylib                      0x180d87e68 _dispatch_call_block_and_release + 32
15  libdispatch.dylib                      0x180d89a2c _dispatch_client_callout + 20
16  libdispatch.dylib                      0x180d91124 _dispatch_lane_serial_drain + 668
17  libdispatch.dylib                      0x180d91c80 _dispatch_lane_invoke + 392
18  libdispatch.dylib                      0x180d9c500 _dispatch_workloop_worker_thread + 648
19  libsystem_pthread.dylib                0x1f0efa0bc _pthread_wqthread + 288
20  libsystem_pthread.dylib                0x1f0ef9e5c start_wqthread + 8

Thread 2:
0   libsystem_pthread.dylib                0x1f0ef9e54 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib                0x1f0ef9e54 start_wqthread + 0

Thread 4:
0   libsystem_pthread.dylib                0x1f0ef9e54 start_wqthread + 0

Thread 5 name:   Dispatch queue: com.google.firebase.firestore.rpc
Thread 5:
0   libsystem_kernel.dylib                 0x1b7e6bbe4 poll + 8
1   uEats                                  0x105264a7c pollset_work(grpc_pollset*, grpc_pollset_worker**, long long) + 3295868 (ev_poll_posix.cc:1026)
2   uEats                                  0x1052667f8 pollset_work(grpc_pollset*, grpc_pollset_worker**, long long) + 3303416 (ev_posix.cc:323)
3   uEats                                  0x1052b37f8 cq_next(grpc_completion_queue*, gpr_timespec, void*) + 3618808 (completion_queue.cc:0)
4   uEats                                  0x105089e1c grpc::CompletionQueue::AsyncNextInternal(void**, bool*, gpr_timespec) + 1351196 (completion_queue_cc.cc:147)
5   uEats                                  0x1053f36e8 firebase::firestore::remote::Datastore::PollGrpcQueue() + 4929256 (datastore.cc:141)
6   uEats                                  0x105423f34 firebase::firestore::util::Task::ExecuteAndRelease() + 5127988 (task.cc:107)
7   libdispatch.dylib                      0x180d89a2c _dispatch_client_callout + 20
8   libdispatch.dylib                      0x180d91124 _dispatch_lane_serial_drain + 668
9   libdispatch.dylib                      0x180d91c80 _dispatch_lane_invoke + 392
10  libdispatch.dylib                      0x180d9c500 _dispatch_workloop_worker_thread + 648
11  libsystem_pthread.dylib                0x1f0efa0bc _pthread_wqthread + 288
12  libsystem_pthread.dylib                0x1f0ef9e5c start_wqthread + 8

Thread 6:
0   libsystem_pthread.dylib                0x1f0ef9e54 start_wqthread + 0

Thread 7:
0   libsystem_pthread.dylib                0x1f0ef9e54 start_wqthread + 0

Thread 8:
0   libsystem_pthread.dylib                0x1f0ef9e54 start_wqthread + 0

Thread 9 name:  com.apple.uikit.eventfetch-thread
Thread 9:
0   libsystem_kernel.dylib                 0x1b7e684e0 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b7e68b24 mach_msg + 76
2   CoreFoundation                         0x181090820 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x181094cac __CFRunLoopRun + 1180
4   CoreFoundation                         0x1810a86b8 CFRunLoopRunSpecific + 600
5   Foundation                             0x18288f414 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236
6   Foundation                             0x1828d0cac -[NSRunLoop(NSRunLoop) runUntilDate:] + 92
7   UIKitCore                              0x183987fb0 -[UIEventFetcher threadMain] + 524
8   Foundation                             0x1828df55c __NSThread__start__ + 808
9   libsystem_pthread.dylib                0x1f0efa9ac _pthread_start + 148
10  libsystem_pthread.dylib                0x1f0ef9e68 thread_start + 8

Thread 10:
0   libsystem_pthread.dylib                0x1f0ef9e54 start_wqthread + 0

Thread 11:
0   libsystem_kernel.dylib                 0x1b7e68f64 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1f0f01298 _pthread_cond_wait + 1236
2   uEats                                  0x10525877c gpr_cv_wait + 3245948 (sync_posix.cc:143)
3   uEats                                  0x1052678d8 grpc_core::Executor::ThreadMain(void*) + 3307736 (executor.cc:238)
4   uEats                                  0x10525bf68 grpc_core::(anonymous namespace)::ThreadInternalsPosix::ThreadInternalsPosix(char const*, void (*)(void*), void*, bool*, grpc_core::Thread::Options const&)::'lambda'(void*)::__invoke(void*) + 3260264 (thd_posix.cc:110)
5   libsystem_pthread.dylib                0x1f0efa9ac _pthread_start + 148
6   libsystem_pthread.dylib                0x1f0ef9e68 thread_start + 8

Thread 12:
0   libsystem_kernel.dylib                 0x1b7e68f64 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1f0f01298 _pthread_cond_wait + 1236
2   uEats                                  0x10525877c gpr_cv_wait + 3245948 (sync_posix.cc:143)
3   uEats                                  0x1052678d8 grpc_core::Executor::ThreadMain(void*) + 3307736 (executor.cc:238)
4   uEats                                  0x10525bf68 grpc_core::(anonymous namespace)::ThreadInternalsPosix::ThreadInternalsPosix(char const*, void (*)(void*), void*, bool*, grpc_core::Thread::Options const&)::'lambda'(void*)::__invoke(void*) + 3260264 (thd_posix.cc:110)
5   libsystem_pthread.dylib                0x1f0efa9ac _pthread_start + 148
6   libsystem_pthread.dylib                0x1f0ef9e68 thread_start + 8

Thread 13:
0   libsystem_kernel.dylib                 0x1b7e68f64 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1f0f01298 _pthread_cond_wait + 1236
2   uEats                                  0x10525876c gpr_cv_wait + 3245932 (sync_posix.cc:0)
3   uEats                                  0x1052732ac timer_thread(void*) + 3355308 (timer_manager.cc:284)
4   uEats                                  0x10525bf68 grpc_core::(anonymous namespace)::ThreadInternalsPosix::ThreadInternalsPosix(char const*, void (*)(void*), void*, bool*, grpc_core::Thread::Options const&)::'lambda'(void*)::__invoke(void*) + 3260264 (thd_posix.cc:110)
5   libsystem_pthread.dylib                0x1f0efa9ac _pthread_start + 148
6   libsystem_pthread.dylib                0x1f0ef9e68 thread_start + 8

Thread 14:
0   libsystem_kernel.dylib                 0x1b7e68f64 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1f0f01298 _pthread_cond_wait + 1236
2   uEats                                  0x10525876c gpr_cv_wait + 3245932 (sync_posix.cc:0)
3   uEats                                  0x1052732ac timer_thread(void*) + 3355308 (timer_manager.cc:284)
4   uEats                                  0x10525bf68 grpc_core::(anonymous namespace)::ThreadInternalsPosix::ThreadInternalsPosix(char const*, void (*)(void*), void*, bool*, grpc_core::Thread::Options const&)::'lambda'(void*)::__invoke(void*) + 3260264 (thd_posix.cc:110)
5   libsystem_pthread.dylib                0x1f0efa9ac _pthread_start + 148
6   libsystem_pthread.dylib                0x1f0ef9e68 thread_start + 8

Thread 15 name:  com.apple.NSURLConnectionLoader
Thread 15:
0   libsystem_kernel.dylib                 0x1b7e684e0 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b7e68b24 mach_msg + 76
2   CoreFoundation                         0x181090820 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x181094cac __CFRunLoopRun + 1180
4   CoreFoundation                         0x1810a86b8 CFRunLoopRunSpecific + 600
5   CFNetwork                              0x181b1e4d8 0x1818a7000 + 2585816
6   Foundation                             0x1828df55c __NSThread__start__ + 808
7   libsystem_pthread.dylib                0x1f0efa9ac _pthread_start + 148
8   libsystem_pthread.dylib                0x1f0ef9e68 thread_start + 8

Thread 16:
0   libsystem_kernel.dylib                 0x1b7e684e0 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b7e68b24 mach_msg + 76
2   CoreFoundation                         0x181090820 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x181094cac __CFRunLoopRun + 1180
4   CoreFoundation                         0x1810a86b8 CFRunLoopRunSpecific + 600
5   Foundation                             0x18288f414 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236
6   Foundation                             0x18288fbd0 -[NSRunLoop(NSRunLoop) run] + 92
7   SwiftUI                                0x188d5eda8 static DisplayLink.asyncThread(arg:) + 836
8   SwiftUI                                0x188d5ca14 @objc static DisplayLink.asyncThread(arg:) + 100
9   Foundation                             0x1828df55c __NSThread__start__ + 808
10  libsystem_pthread.dylib                0x1f0efa9ac _pthread_start + 148
11  libsystem_pthread.dylib                0x1f0ef9e68 thread_start + 8


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000001   x1: 0x0000000000000001   x2: 0x00000001db391b10   x3: 0x000000016aebca69
    x4: 0x0000000000000067   x5: 0x000000000000006a   x6: 0x0000000000000001   x7: 0x0000000199e946bc
    x8: 0x0000000000000000   x9: 0xeff731fd1c940033  x10: 0x000000010d10d4a0  x11: 0x007ffffffffffff8
   x12: 0x0000000000000005  x13: 0x0000000000005e74  x14: 0x0000000000000001  x15: 0x0000000000000005
   x16: 0x00000001f0ef1a50  x17: 0x00000001db3a9cb8  x18: 0x0000000000000000  x19: 0x00000001db3a6e70
   x20: 0x00000001058df758  x21: 0xbcc12b01f4e479e5  x22: 0x000000016aebca30  x23: 0x00000002835943c0
   x24: 0x00000001db391b10  x25: 0x00000002835943c0  x26: 0x000000016aebca60  x27: 0x00000001da3319c8
   x28: 0x000000016aebca40   fp: 0x000000016aebcb90   lr: 0x0000000104f8b4b8
    sp: 0x000000016aebca20   pc: 0x0000000104f8bdec cpsr: 0x60000000
   far: 0x000000010bf201b8  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x104f40000 -        0x105827fff uEats arm64  <4fbe6abe088c32dd9f472d44c6eedf69> /private/var/containers/Bundle/Application/7C7686D2-1729-4FCA-8CFB-B5D3FC5540D3/uEats.app/uEats
       0x180d86000 -        0x180dcbfff libdispatch.dylib arm64e  <69dac9c7ddaf318eb068be596d142a2f> /usr/lib/system/libdispatch.dylib
       0x181089000 -        0x1814defff CoreFoundation arm64e  <d2716f2f688b3d51ba8b17e6553b209e> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
       0x19d141000 -        0x19d149fff GraphicsServices arm64e  <75a910dc87a43b3a8c0ea868b945f5d4> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
       0x1834fa000 -        0x184d94fff UIKitCore arm64e  <e6e89bb5b5863725bf8f4c85dcd443bd> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
       0x188c9f000 -        0x189d36fff SwiftUI arm64e  <9bab2c1c95813bdcbc37fab1ad03dce0> /System/Library/Frameworks/SwiftUI.framework/SwiftUI
       0x105ab4000 -        0x105b0bfff dyld arm64e  <d16b72c0d6193e4892622c10a1d3066f> /usr/lib/dyld
       0x1b7e67000 -        0x1b7e9cfff libsystem_kernel.dylib arm64e  <c2fcc05874803c14b4790064a3f843e3> /usr/lib/system/libsystem_kernel.dylib
       0x1f0ef9000 -        0x1f0f04fff libsystem_pthread.dylib arm64e  <b48efcbed4f7308ba3fa172e0ea78e33> /usr/lib/system/libsystem_pthread.dylib
       0x182877000 -        0x182b7ffff Foundation arm64e  <feeef9b1b0e63561adfa3ef0302d23f8> /System/Library/Frameworks/Foundation.framework/Foundation
       0x1818a7000 -        0x181d67fff CFNetwork arm64e  <eae64611a84036fea69d5658f1bcf4d0> /System/Library/Frameworks/CFNetwork.framework/CFNetwork

EOF

And here is the referenced function


func openOrClosed(restaurant: RestaurantModel) -> String {
        
        //if force close bool value is on
        if restaurant.forceClose {
            return "Closed"
        }
        
        let hoursList = restaurant.hours
        let now = Date()
        let formatter = DateFormatter()
        formatter.dateStyle = .full
        formatter.timeStyle = .short
        
        let datetime = formatter.string(from: now)
        
        let dayOfTheWeek = (datetime.components(separatedBy: ","))[0] //grab current day of week
        let currentTimeColen = (datetime.components(separatedBy: "at "))[1] //grab current time
        
        //converts current time to 24 hr format
        let dateAsString = currentTimeColen
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "h:mm a"
        let date = dateFormatter.date(from: dateAsString)
        dateFormatter.dateFormat = "HH:mm"
        let Date24 = dateFormatter.string(from: date!)
        print(Date24)
        
        //replace : to . so value can be cast as a double
        let decimal = Date24.replacingOccurrences(of: ":", with: ".")
        let currentTime = Double(decimal)
        
        //get array with starthour and closinghour of current day
        guard let currentDayHours = hoursList[dayOfTheWeek] else {
            return "error"
        }
        
        //get range value 1
        guard let openHour = Double(currentDayHours[0]) else {
            return "error"
        }

        //get range value 2
        guard let closeHour = Double(currentDayHours[1]) else {
            return "error"
        }
        
        //create range
        let range = openHour...closeHour
        
        var previousDayOfTheWeek:String = ""
        var previousOpenHour:String = ""
        var previousCloseHour:String = ""
        var previousRange = 0.00...0.00
        var lateTime = 0.00
        var lateExists = false
        
        //db will have p if restaurant closes after midnight
        if currentDayHours.contains("p") {
            previousDayOfTheWeek = currentDayHours[2] //get previous day
            guard let previousDayHours = hoursList[previousDayOfTheWeek] else {
                print(restaurant.name)
                return restaurant.name
            }
            previousOpenHour = previousDayHours[0]//make double
            previousCloseHour = previousDayHours[1]
            previousRange = Double(previousOpenHour)!...Double(previousCloseHour)!
            lateTime = 24.00 + currentTime!
            if lateTime < Double(previousCloseHour)! {
                lateExists = true
            }
            //eventually will get rid of p below
        } else if Double(currentDayHours[0]) ?? 0.0 > 24.00  || Double(currentDayHours[1]) ?? 0.0 > 24.00 {
            //let days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
        }
        
        if range.contains(currentTime!) && (closeHour-currentTime! <= 1.00) && lateExists==false{
            return "Closing Soon"
        } else if lateExists == true && previousRange.contains(lateTime) && (Double(previousCloseHour)! - Double(lateTime) <= 1.00){
            return "Closing Soon"
        } else if range.contains(currentTime!){
            return "Open"
        } else if lateExists == true && previousRange.contains(lateTime){
            return "Open"
        } else {
            return "Closed"
        }
        
    }

Leave a Comment