MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
502 stars 76 forks source link

Bug: Xcode Live previews not working #1180

Open canelson0202 opened 1 year ago

canelson0202 commented 1 year ago

Describe the bug

After generating an .xcodeproj and opening it in Xcode, static canvas previews seem to be working properly, along with automatic preview reloading. However, when a live preview is started, the live preview immediately freezes, and any static previews are broken after that as well.

Reproduction steps

Generate an .xcodeproj using rules_xcodeproj and open it in Xcode. Open any SwiftUI view and try to start a live preview in the canvas.

Expected behavior

Interactive live preview starts.

Versions

Additional context

This project includes some dependencies integrated using apple_dynamic_xcframework_import, apple_static_xcframework_import, and rules_spm

The error that keeps coming up is

<AppName> crashed due to an uncaught exception `NSGenericException`. Reason: Task created in a session that has been invalidated.
brentleyjones commented 1 year ago

That error doesn't seem related to rules_xcodeproj, but something with the way that your previews are setup: https://stackoverflow.com/questions/60636329/task-created-in-a-session-that-has-been-invalidated

Are you able to test this code in a non-rules_xcodeproj Xcode project?

canelson0202 commented 1 year ago

Yeah, this is a project that we are migrating from Xcode's build system to Bazel, and SwiftUI previews and live previews seem to work properly on the original project.

brentleyjones commented 1 year ago

If you are able to create a self-contained reproduction that I can debug, I would be happy to look into it.

brentleyjones commented 1 year ago

I'm going to close this. If you can provide the self-contained reproduction project I can reopen this and debug further. Btw, recent releases and even main have improved SwiftUI Previews support, so maybe this is now fixed for you regardless.

pswaminathan commented 1 year ago

Stack trace:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBLPromise HTTPBody]: unrecognized selector sent to instance 0x600003711fb0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000018040c304 __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x000000018005131c objc_exception_throw + 56
    2   CoreFoundation                      0x000000018041afbc +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
    3   CoreFoundation                      0x0000000180410204 ___forwarding___ + 1308
    4   CoreFoundation                      0x000000018041268c _CF_forwarding_prep_0 + 92
    5   Ergatta                             0x00000001011f87c8 -[GDTCCTUploadOperation updateNextUploadTimeWithResponse:forTarget:] + 64
    6   Ergatta                             0x00000001011f80ac __64-[GDTCCTUploadOperation sendURLRequestWithBatch:target:storage:]_block_invoke + 76
    7   Ergatta                             0x00000001012171d0 __56-[FBLPromise chainOnQueue:chainedFulfill:chainedReject:]_block_invoke.48 + 52
    8   libdispatch.dylib                   0x0000000180133fa4 _dispatch_call_block_and_release + 24
    9   libdispatch.dylib                   0x0000000180135768 _dispatch_client_callout + 16
    10  libdispatch.dylib                   0x000000018013d9d8 _dispatch_lane_serial_drain + 1260
    11  libdispatch.dylib                   0x000000018013e43c _dispatch_lane_invoke + 392
    12  libdispatch.dylib                   0x000000018014a624 _dispatch_workloop_worker_thread + 772
    13  libsystem_pthread.dylib             0x00000001ae55eb40 _pthread_wqthread + 284
    14  libsystem_pthread.dylib             0x00000001ae55d904 start_wqthread + 8
)
brentleyjones commented 1 year ago

@pswaminathan I'm back from vacation now. To jump start my reproduction, can you share how you integrate with Firebase? A sample project that is an iOS app that integrates in the same way would be really helpful (it would probably reproduce this error even).

brentleyjones commented 3 months ago

Without a repro we can't look into this.

pswaminathan commented 3 months ago

Thanks @brentleyjones — we'll work on getting a repro to you. Back on our radar.