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

Using realm-dart alongside RealmSwift #1195

Open
putnokiabel opened this issue Mar 3, 2023 · 17 comments
Open

Using realm-dart alongside RealmSwift #1195

putnokiabel opened this issue Mar 3, 2023 · 17 comments

Comments

@putnokiabel
Copy link

putnokiabel commented Mar 3, 2023

What happened?

We're working on a production Flutter app (on iOS) that's currently using RealmSwift, and we'd would like to migrate to using realm instead for the main app.

However, we need to be able to use both of these side-by-side, since we have native code supporting the home screen widgets and lock screen widgets on iPhone as well as our Apple Watch companion app (which currently also use RealmSwift).

It does not seem possible to compile an iOS app using both, as pod install throws the following exception:
The 'Pods-Runner' target has frameworks with conflicting names: realm.

Is there a way to run both RealmSwift and realm-dart together?

Repro steps

  1. Create a fresh Flutter app supporting iOS (run flutter create -t app --platforms ios test).
  2. Run flutter add realm from the app directory to add the realm package.
  3. Add pod 'RealmSwift', '10.36.0' to ios/Podfile (or any other version of the pod for that matter).
  4. Run pod install from the ios folder.
  5. See the command fail with The 'Pods-Runner' target has frameworks with conflicting names: realm..

The issue persists regardless of the versions of realm or RealmSwift.

Version

1.0.2

What Atlas Services are you using?

Local Database only

What type of application is this?

Flutter Application

Client OS and version

iOS 16

Code snippets

No response

Stacktrace of the exception/crash you're getting

The 'Pods-Runner' target has frameworks with conflicting names: realm.

Relevant log output

No response

@nielsenko
Copy link
Contributor

I must admit this was not a use-case we anticipated. I will investigate.

@nielsenko
Copy link
Contributor

Apparently this should be possible, but right now the name clash prevents it. We will fix this in a coming release. Be aware that the different realm SDKs will still need to agree on the core file format version.

@nielsenko
Copy link
Contributor

A few more caveats..

  1. If you are using sync, then only one SDK can do the syncing. With flutter you can open the realm with Configuration.disconnectedSync which will allow you to open a synchronized realm without starting a sync session. I don't think swift allows this, but as long as one of the SDKs does then it should be good.
  2. This relies on a feature of Mach-O where imported symbol are namespaced according to the shared object they come from - if they were using static linking then we’d be trying to cram two instances of Core in the same binary and they’d clobber each other.
  3. The realm library will essentially be loaded twice in your process.

@putnokiabel
Copy link
Author

@nielsenko Thank you for the quick reply, that sounds great!
The caveats you've mentioned should not be a problem for our use-case, we're not using sync and were already counting on the library being loaded twice to make this work.

@putnokiabel
Copy link
Author

@nielsenko Are there any plans on how (and when) to address the naming conflict with RealmSwift?

@nielsenko
Copy link
Contributor

@putnokiabel This did not make it into 1.1.0, I'm sorry

@ghosharijit
Copy link

@nielsenko , Thank you for the above update. any idea when can we expect the above change?

@JYeop
Copy link

JYeop commented Oct 5, 2023

Same usecase here. Maybe the podspec name should be changed.
(ex: realm -> realm-flutter)

@JYeop
Copy link

JYeop commented Oct 25, 2023

Is there any plan to solve this issue?

@nirinchev
Copy link
Member

Yes, we do intend to provide guidance on how to use Realm from multiple languages in the same app, but don't have timeframe for when that'll be available.

@rjeprasad
Copy link

@nielsenko This is a show-stopper for us. Please update ASAP. Any app with extension + realm will face this issue without a workaround. Just need a name change to remove the naming conflict. Rest should be fine for now.

@nielsenko
Copy link
Contributor

@rjeprasad I'm sorry to hear that.

However, the original Dart team was laid of as part of a restructuring of Realm in September, and I no longer have any say in this, as I'm currently on garden leave.

I see my old colleague @nirinchev, who is the lead on the .NET SDK, and who was helping out on the Dart team previously, has already commented on the road map.

@nirinchev
Copy link
Member

We have this scheduled for later this year.

@ViolyCodevB
Copy link

Is there any progress on this issue?

@nielsenko
Copy link
Contributor

nielsenko commented Feb 18, 2024

@ViolyCodevB We are waiting for flutter/flutter#63240 to be resolved, or native-assets to land. It looks like the latter will happen first.

As is, we would have to have to rename the realm package, which is unlikely to happen for this corner-case.

nielsenko added a commit that referenced this issue Feb 18, 2024
This PR is blocked on #1195
@nielsenko
Copy link
Contributor

I created a branch with the needed changes, but alas it won't work until flutter/flutter#63240 is resolved.

@ramzitannous
Copy link

@nielsenko @nirinchev @rjeprasad is there any solution for this, I'm facing this issue exactly ?

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

9 participants