realm-dart icon indicating copy to clipboard operation
realm-dart copied to clipboard

Using `realm-dart` alongside `RealmSwift`

Open putnokiabel opened this issue 2 years ago • 19 comments

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

putnokiabel avatar Mar 03 '23 13:03 putnokiabel

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

nielsenko avatar Mar 03 '23 13:03 nielsenko

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 avatar Mar 03 '23 14:03 nielsenko

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.

nielsenko avatar Mar 03 '23 14:03 nielsenko

@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 avatar Mar 03 '23 14:03 putnokiabel

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

putnokiabel avatar Mar 28 '23 08:03 putnokiabel

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

nielsenko avatar May 31 '23 14:05 nielsenko

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

ghosharijit avatar Aug 18 '23 14:08 ghosharijit

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

JYeop avatar Oct 05 '23 07:10 JYeop

Is there any plan to solve this issue?

JYeop avatar Oct 25 '23 06:10 JYeop

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.

nirinchev avatar Oct 25 '23 21:10 nirinchev

@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.

rjeprasad avatar Oct 31 '23 07:10 rjeprasad

@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.

nielsenko avatar Oct 31 '23 08:10 nielsenko

We have this scheduled for later this year.

nirinchev avatar Oct 31 '23 10:10 nirinchev

Is there any progress on this issue?

ViolyCodevB avatar Feb 18 '24 06:02 ViolyCodevB

@ViolyCodevB We are waiting for https://github.com/flutter/flutter/issues/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 avatar Feb 18 '24 17:02 nielsenko

I created a branch with the needed changes, but alas it won't work until https://github.com/flutter/flutter/issues/63240 is resolved.

nielsenko avatar Feb 18 '24 17:02 nielsenko

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

ramzitannous avatar Apr 09 '24 22:04 ramzitannous

Hello. Did this issue resolve? Or any suggest to solve? Thanks

sinhpn92 avatar Aug 01 '24 08:08 sinhpn92

@sinhpn92 Sorry, but no. I will make sure to update this issue if it happens. https://github.com/flutter/flutter/issues/63240 is still not resolved, native assets hasn't landed yet (still experimental), and we didn't rename the realm package in order to rename the pod either.

But put a 👍 on the. original issue, so we can monitor interest.

nielsenko avatar Aug 01 '24 09:08 nielsenko