firebase-ios-sdk: SwiftUI Previews crashes on FBLPromise with unrecognized selector

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.5
  • Firebase SDK version: 7.8.1 or 7.11
  • Installation method: Zip file
  • Firebase Component: Analytics, Database, Firestore, Storage

[REQUIRED] Step 2: Describe the problem

With Firebase set up in an iOS app, I cannot run SwiftUI Previews (and just previewing itself crashes frequently). Running the app in a simulator / on a device is fine and doesn’t generate any warnings or errors in the Xcode console output.

This looks very similar to what was reported in #7939, but we’re using the Zip distribution and it only affects SwiftUI previews.

This can be reproduced with a minimal sample app:

Steps to reproduce:

  • Set up a new Xcode project for iOS
  • Set up a Firebase project for the app to get a GoogleService-Info.plist
  • Add Firebase 7.11 (or 7.8.1, both have the same issue) from the zip distribution with the following SDKs:
    • FirebaseAnalytics
    • FirebaseDatabase
    • FirebaseFirestore
    • FirebaseStorage
  • Add import FirebaseCore and FirebaseApp.configure() to the AppDelegate as the zip readme instructs
  • Add a SwiftUI view (if the project isn’t SwiftUI already)
  • Resume the SwiftUI Preview in Xcode (this might already trigger the issue, might not)
  • If the issue hasn’t been triggered by the step above, click the little “Run” button in the Preview Canvas and watch the preview immediately crash

Log from Console.app:

Process:               MyApp [18188]
Path:                  <redacted>
Identifier:            MyApp
Version:               1.0 (1)
Code Type:             ARM-64 (Native)
Parent Process:        launchd_sim [70680]
Responsible:           SimulatorTrampoline [14098]
User ID:               501

Date/Time:             2021-04-29 11:28:37.611 +0200
OS Version:            macOS 11.3 (20E232)
Report Version:        12
Anonymous UUID:        <redacted>

Sleep/Wake UUID:       <redacted>

Time Awake Since Boot: 120000 seconds
Time Since Wake:       15000 seconds

System Integrity Protection: enabled

Crashed Thread:        7  Dispatch queue: com.google.GDTCCTUploader

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBLPromise HTTPBody]: unrecognized selector sent to instance 0x600001ea4720'
terminating with uncaught exception of type NSException
abort() called
CoreSimulator 757.5 - Device: iPhone 12 Pro (4631766E-9C43-461C-8EB6-2B639CEE6CB0) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 12 Pro

Application Specific Backtrace 1:
0   CoreFoundation                      0x0000000104599978 __exceptionPreprocess + 236
1   libobjc.A.dylib                     0x0000000103719800 objc_exception_throw + 56
2   CoreFoundation                      0x00000001045a8f14 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3   CoreFoundation                      0x000000010459dbf0 ___forwarding___ + 1408
4   CoreFoundation                      0x000000010459fe7c _CF_forwarding_prep_0 + 92
5   MyApp                               0x0000000102ab0024 -[GDTCCTUploadOperation updateNextUploadTimeWithResponse:forTarget:] + 64
6   MyApp                               0x0000000102aaf8d0 __64-[GDTCCTUploadOperation sendURLRequestWithBatch:target:storage:]_block_invoke + 76
7   MyApp                               0x0000000102aac514 __56-[FBLPromise chainOnQueue:chainedFulfill:chainedReject:]_block_invoke.48 + 52
8   libdispatch.dylib                   0x0000000109f4a580 _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x0000000109f4bd44 _dispatch_client_callout + 16
10  libdispatch.dylib                   0x0000000109f52dcc _dispatch_lane_serial_drain + 968
11  libdispatch.dylib                   0x0000000109f537f8 _dispatch_lane_invoke + 400
12  libdispatch.dylib                   0x0000000109f5da58 _dispatch_workloop_worker_thread + 744
13  libsystem_pthread.dylib             0x00000001bca3b754 _pthread_wqthread + 272
14  libsystem_pthread.dylib             0x00000001bca3a524 start_wqthread + 8

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00000001bc9fe470 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001bc9fe814 mach_msg + 72
2   com.apple.CoreFoundation      	0x000000010450783c __CFRunLoopServiceMachPort + 368
3   com.apple.CoreFoundation      	0x0000000104501d3c __CFRunLoopRun + 1136
4   com.apple.CoreFoundation      	0x00000001045013bc CFRunLoopRunSpecific + 572
5   com.apple.GraphicsServices    	0x0000000114dc770c GSEventRunModal + 160
6   com.apple.UIKitCore           	0x000000010e0eb3d0 -[UIApplication _run] + 964
7   com.apple.UIKitCore           	0x000000010e0f01ac UIApplicationMain + 112
8   libswiftUIKit.dylib           	0x0000000109cf316c UIApplicationMain(_:_:_:_:) + 100
9   com.example.MyApp              	0x0000000102aa3294 static UIApplicationDelegate.main() + 120
10  com.example.MyApp              	0x0000000102aa320c static AppDelegate.$main() + 108 (AppDelegate.swift:11)
11  com.example.MyApp              	0x0000000102aa332c main + 32
12  libdyld.dylib                 	0x0000000109fdd554 start + 4

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 18 (7 by maintainers)

Most upvoted comments

This is unfortunately still an issue, just tested with Xcode 13.3 and Firebase 8.14.0 and can still reproduce. As of Xcode 13.3 there’s no longer a need to go looking for error logs, they open immediately when trying to preview ContentView.swift in the sample project (which I’ve also updated, now importing Firebase via SPM).

Are there any updates or “simpler” fixes to get around this? Sadly, it’s still possible to reproduce the issue for projects targeting iOS 13 on Xcode 13.3.1.

Using Xcode 14.2, iOS 16.2 simulator, Firebase SDK 8.10.0 via Carthage, this issue is reproducible. Crash log is exactly the same as reported.

The strange thing is, it worked quite fine for 2 days, then it started crashing. Now it’s not working at all, crashing immediately.

I’m hoping for a resolution to this 2 year old, reproducible issue.

This should be addressed in Promises 2.3.1 that is planned to be shipped with the Firebase 10.13.0 binary distributions

Is this happening in live previews as well?

Yes

Opened https://github.com/google/promises/issues/189 to explore a Promises fix

@simba909 Thanks for the great repro. I’m able to reproduce. Unfortunately, I don’t have any immediate solutions. It really looks like a bug with SwiftUI Preview.

Some possible next steps:

  • Report the issue as is to Apple
  • Try to reduce the crash to only Promises and fewer clients
  • Follow up on Promises support channels
  • Experiment with forcing linkage to the missing symbols from other libraries or the main app

Thanks for the reply @simba909 I haven’t been able to figure out any workarounds for it either. Makes any development using SwiftUI impossible 😕

Using SPM isn’t an option for me yet since google sign in is still not supported.