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

Kotlin-Native support for multiplatform development #601

Open
jittya opened this issue Nov 4, 2018 · 27 comments
Open

Kotlin-Native support for multiplatform development #601

jittya opened this issue Nov 4, 2018 · 27 comments
Labels
enhancement New feature or request help wanted Looking for insight or contributors

Comments

@jittya
Copy link

jittya commented Nov 4, 2018

Note: There is a helpful Stack Overflow response about this.


is there any way that i can use objectbox in kotlin native module and share the bussiness logics in android and ios modules ?

@greenrobot greenrobot added the enhancement New feature or request label Nov 4, 2018
@greenrobot
Copy link
Member

This would require major changes, so it's nothing we could do on the fly. Let's see how many people would be interested in this.

@abdurahmanadilovic
Copy link

I don't think this is an objectbox issue. Objectbox is just an external library for the Android platform and it has to exist within an Android module, nothing can be shared on other platforms with regards to ObjectBox. You can, however, have a local data source interface for your models that will be implemented on each platform separately and ObjectBox will do that for the Android platform.

@zydeco
Copy link

zydeco commented Nov 20, 2018

I don't think this is an objectbox issue. Objectbox is just an external library for the Android platform and it has to exist within an Android module

The 4th item on objectbox.io is "cross platform", and supporting Kotlin/Native would allow using ObjectBox in cross platform projects, which is currently not possible without implementing a higher level abstraction layer.

It does seem like a major change, it would at least require converting all the java classes to kotlin, and in the native implementation, call the C library from kotlin instead of using JNI.

@seyedjafariy
Copy link

is there an internal branch for this? can we make any contributions?

@JavierSegoviaCordoba

This comment was marked as duplicate.

@thanhhai08sk

This comment was marked as duplicate.

@greenrobot
Copy link
Member

It does seem like a major change, it would at least require converting all the java classes to kotlin, and in the native implementation, call the C library from kotlin instead of using JNI.

Very good observation. Because of that effort, we'll watch how much interest this feature request generates. With our limited resources, we will not start on this immediately though.

There is a theoretic approach using the C API with Kotlin MP, but that is won't be (as) pretty...

@CarsonRedeye
Copy link

It does seem like a major change, it would at least require converting all the java classes to kotlin, and in the native implementation, call the C library from kotlin instead of using JNI.

Very good observation. Because of that effort, we'll watch how much interest this feature request generates. With our limited resources, we will not start on this immediately though.

There is a theoretic approach using the C API with Kotlin MP, but that is won't be (as) pretty...

Has anyone attempted this?

@atulgpt

This comment was marked as duplicate.

@Ditscheridou

This comment was marked as duplicate.

@AronMitk

This comment was marked as duplicate.

@TomislavMladenov

This comment was marked as duplicate.

@TonnyL

This comment was marked as duplicate.

@greenrobot greenrobot added the help wanted Looking for insight or contributors label Jul 30, 2021
@kihaki

This comment was marked as spam.

@brandonpollack23

This comment was marked as spam.

1 similar comment
@galacticfungus

This comment was marked as spam.

@ArtemMikhaylov
Copy link

In the meantime Kotlin multiplatform gone beta :) Is there any update about support kmm for android and ios?

@jittyandiyan

This comment was marked as off-topic.

@ArtemMikhaylov

This comment was marked as off-topic.

@fcat97

This comment was marked as duplicate.

@JavierSegoviaCordoba
Copy link

You have more alternatives for Multiplatform storage: Realm, Sqldelight, Datastore, Multiplatform Settings... No need for Flutter.

@greenrobot-team
Copy link
Member

greenrobot-team commented Jul 10, 2023

@fcat97 Not Kotlin multi-platform, but ObjectBox is also available for Flutter.

Edit: There is also a helpful Stack Overflow response about this.

@sebastianharder
Copy link

Kotlin Multiplatform is now stable. I think, it's a huge opportunity for ObjectBox. Any storage option not supporting Kotlin Multiplatform will probably soon become irrelevant.

@NobilityDeviant
Copy link

NobilityDeviant commented Feb 26, 2024

I don't understand why it doesn't work. It works with Kotlin and JavaFX on all 3 Windows, Mac & Linux.
Now I switch to Compose Multi and something breaks. ToMany & ToOne relationships are completely useless. I have managed to make them persist a little bit but then something breaks. Why is this?
There is no hope for longevity.
I am just going to have to ditch the relationships entirely since they don't persist.
Might be slow but at least it'll work.

Just to clarify for anybody potentially reading this.
ObjectBox does in fact work with Compose Multiplatform.
It syncs, it persists regular entities and queries everything just fine.
The only problem that I'm having is the ToMany & ToOne relationships are not working properly.
I keep saving them and then I query them, but there's only 1 entity or none in the ToMany list.
You even have to add some extra code for it to even work in the first place like the BoxStore inside the class and you have to attach the entity.
It's just so odd. I really hope I can figure something out before switching databases entirely.

@greenrobot-team
Copy link
Member

greenrobot-team commented Feb 26, 2024

@NobilityDeviant This is likely because the bytecode transformer included in the ObjectBox Gradle plugin does not run. It only works for Java JVM or Android projects. See https://docs.objectbox.io/relations#initialization-magic for details and maybe manual steps you can take.

@NobilityDeviant
Copy link

@NobilityDeviant This is likely because the bytecode transformer included in the ObjectBox Gradle plugin does not run. It only works for Java JVM or Android projects. See https://docs.objectbox.io/relations#initialization-magic for details and maybe manual steps you can take.

Sorry i was really upset the other night.
I created some abstract entity system on top of objectbox and it turns out it was just my fault for not doing it properly.
It's all working well now.

@devjn
Copy link

devjn commented May 26, 2024

Since Android team is now officially supporting Kotlin Multiplatform for shared business logic, is there going to be any progress towards kotlin multiplatform for ObjectBox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Looking for insight or contributors
Projects
None yet
Development

No branches or pull requests