Skip to content

Comments

fix/iOS: Load realm-wrapper DLL using MainBundle.PrivateFrameworksPath#3714

Closed
EmilienDup wants to merge 1 commit intorealm:mainfrom
EmilienDup:fix/3711
Closed

fix/iOS: Load realm-wrapper DLL using MainBundle.PrivateFrameworksPath#3714
EmilienDup wants to merge 1 commit intorealm:mainfrom
EmilienDup:fix/3711

Conversation

@EmilienDup
Copy link

@EmilienDup EmilienDup commented Nov 25, 2025

Description

Fixes #3711.
Allows Realm to work in net10-ios apps.

This change is minimal.
It is based on this comment.
Ideally I think it would have been better to delegate the wrappers initialization to the platform level (Windows & iOS).
But as the platform level code is not part of the main assembly, changing the resolver of another assembly is not recommended.

As I am developing on a Mac, I encountered a lot of hiccups when trying to build the various projects.
Based on my testings it should work fine on net8-ios and net10-ios, but if it is possible to generate nuget packages from my PR, I would like to test them in a standalone app to make sure everything works well once packaged up.

TODO

  • Changelog entry
  • Tests

@cla-bot
Copy link

cla-bot bot commented Nov 25, 2025

Realm welcomes all contributions! The only requirement we have is that, like many other projects, we need to have a Contributor License Agreement (CLA) in place before we can accept any external code. Our own CLA is a modified version of the Apache Software Foundation’s CLA. Our records show that CLA has not been signed by @EmilienDup. Please submit your CLA electronically using our Google form so we can accept your submissions. After signing the CLA you can recheck this PR with a @cla-bot check comment. The GitHub usernames you file there will need to match that of your Pull Requests. If you have any questions or cannot file the CLA electronically, make a comment here and we will be happy to help you out.

Copy link

@ravikiransharmadev ravikiransharmadev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes approved for iOS

@nirinchev nirinchev changed the base branch from main to community December 12, 2025 15:20
@nirinchev
Copy link
Member

@EmilienDup can you please rebase this work on the community branch? The main branch is pointing to the now-deprecated sync-capable version of the SDK.

@EmilienDup
Copy link
Author

On the community branch, there is no Realm.PlatformHelpers project.

I can probably add it, but as Realm.PlatformHelpers is distributed as a dedicated nuget package, how should it work from a versioning perspective?
Currently the version is 12.5.0, should it be bumped to 20.X.Y?

Another solution could be to add net8.0-ios as a target platform for Realm.csproj

- <TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
+ <TargetFrameworks>netstandard2.0;net6.0;net8.0;net8.0-ios</TargetFrameworks>

But there might be a good reason why Realm.csproj is only targeting platform independent frameworks.

@nirinchev nirinchev changed the base branch from community to main December 15, 2025 11:46
@nirinchev
Copy link
Member

Oh... that's a good point. Yeah, I think adding platform-specific TFMs can open a can of worms we don't want to open right now 😬

Without major rework, I think our best path forward is probably the reflection change you proposed in #3711 (comment). My only suggestion there is to use a runtime check instead of a preprocessor directive since that will not work when the binary is built against an earlier .NET version. I.e. instead of #if NET10_0_OR_GREATER, we should probably have if (System.Environment.Version.Major >= 10) like you do in this PR.

@EmilienDup
Copy link
Author

EmilienDup commented Dec 15, 2025

Yeah, the reflection change seems to be the easiest change for now.

I will probably open a new PR targeting the community branch then

@EmilienDup
Copy link
Author

Closing in favor of #3718

@EmilienDup EmilienDup closed this Dec 15, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting error The type initializer for 'Realms.SharedRealmHandle' threw an exception. System.DllNotFoundException: realm-wrappers

3 participants