Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when embedding molecule into an XCFramework and running it on an iOS app #547

Open
danielPerez97 opened this issue Nov 28, 2024 · 4 comments

Comments

@danielPerez97
Copy link

danielPerez97 commented Nov 28, 2024

Hello. I'm not entirely sure this is an error with Molecule itself or I am just setting up the Gradle code for building the XCFramework poorly. Any help would be appreciated. I am building a Kotlin Multiplatform module that uses Molecule for iOS and trying to run it mixed with Swift code.

Here is the error in XCode:

Thread 3: EXC_BAD_ACCESS (code=1, address=0x0)
    0x106a7efe4 <+752>:  bl     0x106a7f97c               ; _6d6f6c6563756c653a6d6f6c6563756c652d72756e74696d652f55736572732f72756e6e65722f776f726b2f6d6f6c6563756c652f6d6f6c6563756c652f6d6f6c6563756c652d72756e74696d652f7372632f71756172747a436f72654d61696e2f6b6f746c696e2f6170702f636173682f6d6f6c6563756c652f446973706c61794c696e6b436c6f636b2e6b74_knbridge18
->  0x106a7efe8 <+756>:  b      0x106a7efec               ; <+760> at DisplayLinkClock.kt:36:93
    0x106a7efec <+760>:  bl     0x105952070               ; Kotlin_mm_switchThreadStateRunnable_debug
    0x106a7eff0 <+764>:  b      0x106a7eff4               ; <+768> at DisplayLinkClock.kt

I've put the code in this repo. Running the Android app works perfectly using the :Frontend module, but just not having the same luck on iOS.
https://github.com/danielPerez97/Pourover/

Steps to Recreate:

  1. Run gradlew Frontend:assembleFourSixFrontendLibDebugXCFramework:
  2. Copy the XCFramework at Frontend/build/XCFrameworks/debug/FourSixFrontendLib.xcframework into iOS/Pourover
  3. Run the iOS app on a simulator

Like I said I'm not sure this is a Molecule issue, and feel free to close it if it isn't.

Edit: Using XCode 16 + Swift 5

@JakeWharton
Copy link
Collaborator

We also have a display link clock in Redwood, so it's possible we need to port over some improvements from it.

@danielPerez97
Copy link
Author

danielPerez97 commented Nov 28, 2024

Hmm, I may try to rip the DisplayLinkClock code from Redwood, and rebuild Molecule locally with some includeBuild() magic then. Would this be the file to rip?

https://github.com/cashapp/redwood/blob/7773cd4b73c0f9b00e7459b8f54f61459b02eda6/redwood-compose/src/iosMain/kotlin/app/cash/redwood/compose/DisplayLinkClock.kt#L30

I'm completely new to getting a Kotlin Multiplatform library to run on iOS, if there's any way you know where I can get you better error messages I'd be happy to enable whatever I need to. I'm really unsure if this is even a Molecule issue.

Edit: It seems there is some redwood-specific stuff in the DisplayLInkClock. I'll just wait on an update, thanks for the help.

@JakeWharton
Copy link
Collaborator

This is the one we use in production: https://github.com/cashapp/redwood/blob/trunk/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/IosDisplayLinkClock.kt

It's not exactly the same setup as a "normal" FrameClock, but it drives an abstraction which is nearly identical.

@danielPerez97
Copy link
Author

I'm not sure if this is related, but I did find this article. Only linking because XCode also tells me EXC_BAD_ACCESS. I'll try to give this solution a spin this week.

https://www.nutrient.io/blog/dynamic-linking-crash-xcode-16/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants