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

XCFramework is crashing with latest RealmSwift version on Real.configuration #8218

Open
amirpervaizQI opened this issue Apr 25, 2023 · 12 comments

Comments

@amirpervaizQI
Copy link

amirpervaizQI commented Apr 25, 2023

How frequently does the bug occur?

Always

Description

Hi,
I am making XCFrameworkk with the -ObjC linkers as mentioned in another thread. Realmswift v10.38.0 is a dependency in the podspecs file.

xcodebuild -create-xcframework \
    -framework "./build/ios.xcarchive/Products/Library/Frameworks/sdk.framework" \
    -framework "./build/ios_sim.xcarchive/Products/Library/Frameworks/sdk.framework" \
    -output "./build/sdk.xcframework"
    -ldflags "-Wl,-ObjC"

but it is crashing on init Realm at configuration. Please see the screenshot below:

Screenshot 2023-04-25 at 10 41 18 AM

I am using RealSwift 10.38.0 and have tried a few older versions but getting the same error. It used to work with 10.19.0.

It also working when I use the code instead of XCFramework. Could you please check this issue?

Thanks.

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

10.38.0

What Atlas Services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

iOS 16.3

Build environment

Xcode version: Version 14.2 (14C18)
Dependency manager and version: Cocoapods 1.12.1

@amirpervaizQI amirpervaizQI changed the title XCFramework is crashing with latest RealmSwift XCFramework is crashing with latest RealmSwift version on Real.configuration Apr 25, 2023
@leemaguire
Copy link
Contributor

Hi @amirpervaizQI, can you try producing the XCFrameworks with our build script instead?

Clone the realm-swift repo and then run ./build.sh xcframework ios

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Apr 25, 2023
@amirpervaizQI
Copy link
Author

Hi @leemaguire thank you for your reply. Sorry If I didnt explain my question clearly. I am building a custom XCFramework and that is using RealmSwift as a dependency. When I build my XCFramework and distribute it via cocoapods by using Realm dependency as s.dependency 'RealmSwift', '10.38.0' in my podspecs file. Then, it is throwing the above crash in an app.

Whereas when I use my custom Framework via code with RealSwift in the app, I dont observer any crash. The issue is happening with the latest swift versions with the XCFramework. Though it seems to be working with an older version 10.19.0.

Should I make Realm/RealmSwift XCFramework with the script and use it in my Framework?

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Apr 26, 2023
@dianaafanador3
Copy link
Contributor

dianaafanador3 commented May 24, 2023

Hi @amirpervaizQI I was able to reproduce your issue and I was able to find a workaround
One solution will be to set to BUILD_LIBRARY_FOR_DISTRIBUTION=NO when you archive your frameworks and add -allow-internal-distribution when you create your xcframework.There may be some Apple's issues in swift-evolution which may be causing some issues which may be causing this crashes, this will allow you to append the RealmSwift SDK using cocoapods.
If you do want to set BUILD_LIBRARY_FOR_DISTRIBUTION to YES
Yo can generate Realm and RealmSwift xcframework ./build.sh xcframework ios like it was suggested above and link it to your framework, generate your xcframework and then add the three xcframeworks to your app (Your framework, RealmSwift and Realm).
I tested both approaches and they seem to be working, let me know if this is helpful.

@sync-by-unito sync-by-unito bot added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed and removed Needs-Attention Reporter has responded. Review comment. labels May 24, 2023
@amirpervaizQI
Copy link
Author

amirpervaizQI commented May 26, 2023

Thanks @dianaafanador3 , I got these errors when I try to compile my framework with Realm.xcframework and RealmSwift.xcframework manually created by the above command you mentioned.

Screenshot 2023-05-26 at 3 37 35 PM

Using Xcode 14.3 and used the XCFramework in swift-14.3 folder.

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels May 26, 2023
@dianaafanador3
Copy link
Contributor

@amirpervaizQI is this missing symbol only for the current architecture?
Can you please share which Xcode, RealmSwift and target device version are you using?

@amirpervaizQI
Copy link
Author

-Xcode 14.3
-pod: 1.12.0
-For RealmSwift, I pulled the latest code from the master branch. I believe the release is 10.39.1. I am compiling Framework for arAny iOS Device (arm64)

@dianaafanador3
Copy link
Contributor

@amirpervaizQI how are you importing the xcframework into your own framework?.
I'm attaching a simple example project, where it's building correctly.
SupportXCFramework.zip

@sync-by-unito sync-by-unito bot added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed and removed Needs-Attention Reporter has responded. Review comment. labels May 31, 2023
@amirpervaizQI
Copy link
Author

amirpervaizQI commented Jun 27, 2023

Hi @dianaafanador3 thank you so much for sharing the sample app. I checked it and it worked in the sample app. However, in my case, I cant embed RealmSwift inside of the XCFramework. The above error occurs while integrating from pod. I tried the latest pod but still the same. I think its linked with BUILD_LIBRARY_FOR_DISTRIBUTION what you mentioned above.

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jun 27, 2023
@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Jul 28, 2023
@sync-by-unito sync-by-unito bot removed the T-Bug label Sep 12, 2023
@amirpervaizQI
Copy link
Author

amirpervaizQI commented Nov 29, 2023

Hi @dianaafanador3 could you pls check what got changed from 10.21.0 onwards that broke the RealmSwift in an XCFramework? I found this ticket #7989 it explains the same issue. I would appreciate your help looking into it. I just tried the latest version 10.44.0 but still it breaks when used as a dependency in the XCFramework.

thanks.

@github-actions github-actions bot removed the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Nov 29, 2023
@amirpervaizQI
Copy link
Author

Still looking for a fix. Please update.

@themoonlitknight
Copy link

Check out this workaround #7989 (comment)

@amirpervaizQI
Copy link
Author

Hi @dianaafanador3 I recently tested one of my old project - which was originally created using Xcode 11 - on Xcode 15.3. Surprisingly, I didnt encounter any crashes while running the XCFramework with RealmSwift as a dependency. I am wondering this could be RealmSwift compatibility issue or Xcode linkers? Any insights you might have on this matter would be greatly appreciated. Thank you.

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

No branches or pull requests

4 participants