how to remove realm database used in swift iOS in .NET MAUI?

Nam Pham 126 Reputation points
2023-10-02T03:18:00.0066667+00:00

Hello,

I rebuild iOS app using .NET MAUI.

There was data stored in realm database in iOS app.

In MAUI, i want to remove it because it's no longer needed.

Is there any way to do that?

update

Hello I mean that i build MAUI with the same configuration of Native app which is using swift. MAUI will override Native app not a separate app.

for example: iOS Native app using swift with version 1.0.0, i will build MAUI app with the same configuration and version of the app is 2.0.0. Hence, users just update app installed in their device. Because in iOS native app i used Realm database, but in MAUI i don't use it. therefore, i want to remove it for reducing the App size. (if i don't remove it, data stored in it is still alive).

so, is this possible to remove Realm database used in Native app in MAUI?

Thanks

Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2023-10-03T05:14:43.6133333+00:00

    Hello,

    When you build a native iOS app, Realm Database is a library not developed by Apple that you can install into your swift iOS projects through the Swift Package Manager or reference the library directly.

    When you develop apps with MAUI cross-platform framework, you create a new MAUI project that doesn't have any third-party packages referenced.

    In MAUI, i want to remove it because it's no longer needed. Is there any way to do that?

    You don't need to do anything, just develop in your new MAUI project. (Or the library as a binding is referenced in your MAUI project, just remove it)

    Update

    I got it. You just want to remove the database storage, right? If so, it's suggested that you update a new version with native swift. In this version, you could remove all database data, such as delate all entries, all tables and all databases. (I'm not sure if that third-party Realm Database supports to remove database itself).

    Another solution

    Realm persists data in files saved on device storage. You could try to find the file path, then delate it with MAUI, see MAUI File system helpers.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.