No gonna lie, today i was decided to implement Rom in KMP with the documentation provided for google. And Philipp comes with this video, it is truly insane. Philipp you saved my day, tanks a lot!!!
I used to have roomdb then wanted to migrate for kotlin multiplatform so changed to sqldelight. Now room is available for kotlin multi platform too. Too late 😂😂😂
@@FreedivingTrainer I think roomdb has better performance also one think I don't like about sqldelight is that all transaction content should be synchronous you can't use suspend functions. Also I don't like the too much code you have to write in sqldelight
Great video, thanks! By the way, context exists on iOS as well. Core Data, which is the native persistence method in iOS, uses it too. However, for some reason, Kotlin databases on iOS, like Room or SQLDelight, don't seem to require it.
For Kotlin 2.0.0, there seems to be an issue syncing 'Cannot change attributes of configuration ':composeApp:debugFrameworkIosX64' after it has been locked for mutation', have used the latest KSP so that IDE identifies generated sources, but still throwing this error. Any one had any luck with this?
I had the same issue. Replace (for now) : dependencies { //room //Replace it with -> ksp(libs.room.compiler) when it is stable add("kspCommonMainMetadata", libs.room.compiler) } tasks.withType().configureEach { if (name != "kspCommonMainKotlinMetadata" ) { dependsOn("kspCommonMainKotlinMetadata") } } I think they will notice and they will come up with a change.
Cannot change attributes of configuration ':composeApp:debugFrameworkIosX64' after it has been locked for mutation Guys anyone know how do solve this error
Philipp many thanks for the video explanation. Could you explain how to implement dependency injection in this project? how to inject the room database in the viewmodel, shared amongst Android and iOS? thanks, best regards
Hi Phillip, You will know how to implement PagingSource, to a room dao function, if currently room for kmp only allows you to place the function as suspend or Flow
Thank you for your extremely helpful content! I found an issue that the database is closed in app inspector, even if the app run and doing sql CRUD. I can't see my live database. Do you have any idea?
On a physical iOS device (iPhone), I encountered an error when using NSHomeDirectory in the databaseBuilder: Error Domain=KotlinException Code=0 "Unable to open lock file (Operation not permitted)". However, this issue did not occur on the simulator, where it worked fine. To resolve this, I replaced: val dbFile = NSHomeDirectory() + "/myDatabase.db" with val docDirectoryUrl = NSFileManager.defaultManager().URLForDirectory(NSDocumentDirectory, NSUserDomainMask, null, true, null) val dbFile = docDirectoryUrl?.path + "/myDatabase.db" and it worked fine. Does anyone have other suggestions? Thanks.
Philip is it safe to use compose multiplatform for production in this point or is it a bit risky with alpha version? (Jetbrains focus to release beta this year)
Hey Philipp, great video! However, I noticed that you did all of your code in :composeApp. Why did you take this approach and not in the :shared module? I was under the impression that :shared is used for business logic...
composeApp is a shared module. Right now, they shipped android and kmm together into one module named composeApp by default if you create project from kmp wizard.
@@deriarmanda7807 Yeah that was quite confusing for me. Now I use `shared/` module for stuff that is shared between the app the server like serializing request/response bodies and type-safe routing.
@@PhilippLackner I don't think that I missed a video for you, I mean if there is an existing android project, how to migrate its settings and configurations to be a kmp one
Hii Philipp.. KSP has generate source code but instantiateImpl() is not resolved in iOS SourceSet. But it is resolved in Android SourceSet. I couldn't figure out the root cause. I have checked generated build folder. I found the method in both iOS & Android generated files but am not getting why it is not resolved in iOS source set resulting in build failure. Please help us to resolve this.
If some one from subscriber knows how to login to account on pl-coding, please reply. I am not able to see a way to login on pl-coding. I want to access course that I enrolled for.
After the purchase you got an email with instructions to set a password on Memberspot. Then you just need to log in there with the link in the email :)
For now, there are a new way to define ksp dependency(also recommended by Jetbrains) ```Kotlin dependencies { add("kspAndroid", libs.utils.db.room.compiler) add("kspIosSimulatorArm64", libs.utils.db.room.compiler) add("kspIosX64", libs.utils.db.room.compiler) add("kspIosArm64", libs.utils.db.room.compiler) add("kspJvm", libs.utils.db.room.compiler) } ```
There it is, nice! Next video suggestions:
- Preparing for Kotlin 2.0
- Compose Preview Screenshot testing
No gonna lie, today i was decided to implement Rom in KMP with the documentation provided for google. And Philipp comes with this video, it is truly insane.
Philipp you saved my day, tanks a lot!!!
I see Room docs and this video, prefer to stay with sqlDelight for multiplatform
Philipp, I spent two days trying to do this, and here’s your video! Lord, give you everything you want and thank you so much
Glad I could help!
Thank you Philipp, extremely helpful content. I'll stick to realm, but good to know room is now also supported.
I used to have roomdb then wanted to migrate for kotlin multiplatform so changed to sqldelight. Now room is available for kotlin multi platform too. Too late 😂😂😂
I see Room docs and this video, prefer to stay with sqlDelight for multiplatform :)
@@FreedivingTrainer I think roomdb has better performance also one think I don't like about sqldelight is that all transaction content should be synchronous you can't use suspend functions. Also I don't like the too much code you have to write in sqldelight
Great video, thanks! By the way, context exists on iOS as well. Core Data, which is the native persistence method in iOS, uses it too. However, for some reason, Kotlin databases on iOS, like Room or SQLDelight, don't seem to require it.
Interesting, they're still two different contexts though 😄
Hi Philipp, Can we use Room for Desktop also ?
Duh.
yes you can use it on desktop
Ive foudn th best kotlin youtuber.
For Kotlin 2.0.0, there seems to be an issue syncing 'Cannot change attributes of configuration ':composeApp:debugFrameworkIosX64' after it has been locked for mutation', have used the latest KSP so that IDE identifies generated sources, but still throwing this error. Any one had any luck with this?
Philips this error is emerged from Kotlin 2.0.0 and KSP 2.0.0.
Could you please help ?
i have same error
same...
I had the same issue.
Replace (for now) :
dependencies {
//room
//Replace it with -> ksp(libs.room.compiler) when it is stable
add("kspCommonMainMetadata", libs.room.compiler)
}
tasks.withType().configureEach {
if (name != "kspCommonMainKotlinMetadata" ) {
dependsOn("kspCommonMainKotlinMetadata")
}
}
I think they will notice and they will come up with a change.
@@panagiotismargaritis3531 For me it still not work, throws error -> error: Unresolved reference 'instantiateImpl'.
please create a playlist for KMP videos on your channel for better access 🙏
Cannot change attributes of configuration ':composeApp:debugFrameworkIosX64' after it has been locked for mutation
Guys anyone know how do solve this error
yes deps should look like this now:
dependencies {
// Room
add("kspAndroid", libs.room.compiler)
afterEvaluate {
add("kspIosSimulatorArm64", libs.room.compiler)
add("kspIosX64", libs.room.compiler)
add("kspIosArm64", libs.room.compiler)
}
}
Philipp many thanks for the video explanation. Could you explain how to implement dependency injection in this project? how to inject the room database in the viewmodel, shared amongst Android and iOS? thanks, best regards
Check my recent video on how to share ViewModels and then connect these two :)
damn Philipp!
you're speeding up! ❤
Hi Phillip, You will know how to implement PagingSource, to a room dao function, if currently room for kmp only allows you to place the function as suspend or Flow
Danke man, ich liebe deine Videos.
Thank you for your extremely helpful content!
I found an issue that the database is closed in app inspector, even if the app run and doing sql CRUD. I can't see my live database. Do you have any idea?
Same here 😥
error: Unresolved reference 'instantiateImpl'
Same issue here. Did anyone found the root cause and resolved this issue?
@@VikramKirubaharan Pay attention on using instantiateImpl() - it is only for ios code
@philipp Do you have any idea how I can create a database instance with Koin?
Could you make Playlist for KMP?
damn i feel like u read my mind, thats what i was looking for :)
🎉🎉🎉 keep going
On a physical iOS device (iPhone), I encountered an error when using NSHomeDirectory in the databaseBuilder: Error Domain=KotlinException Code=0 "Unable to open lock file (Operation not permitted)". However, this issue did not occur on the simulator, where it worked fine. To resolve this, I replaced:
val dbFile = NSHomeDirectory() + "/myDatabase.db"
with
val docDirectoryUrl = NSFileManager.defaultManager().URLForDirectory(NSDocumentDirectory, NSUserDomainMask, null, true, null)
val dbFile = docDirectoryUrl?.path + "/myDatabase.db"
and it worked fine. Does anyone have other suggestions? Thanks.
this helped me as well
You saved my life! Thank you........
You also saved my life and my a**, super thank you man
Philip is it safe to use compose multiplatform for production in this point or is it a bit risky with alpha version? (Jetbrains focus to release beta this year)
I wouldn't yet
Hi, whats your theme in Android Studio?
Could you please integrating it with koin in kmm
Guys when cmp will usable and common you think ?
How can you have code suggestion on kotlin files of iosMain package? Mine Android studio only treated like a plain text files :(
I see Room docs and this video, prefer to stay with sqlDelight for multiplatform ;)
I am facing some troubles because iOS requires ConstructedBy tag.
Is it not compatible with wasm ?
Hey Philipp, great video! However, I noticed that you did all of your code in :composeApp. Why did you take this approach and not in the :shared module? I was under the impression that :shared is used for business logic...
composeApp is a shared module. Right now, they shipped android and kmm together into one module named composeApp by default if you create project from kmp wizard.
@@deriarmanda7807 Yeah that was quite confusing for me. Now I use `shared/` module for stuff that is shared between the app the server like serializing request/response bodies and type-safe routing.
How to add dao on wasm and desktop app
how about migrate ?
Would this be the same way to implement room in an intellij desktop project?
I want to know this too
Yes for Desktop it works as well
@@PhilippLacknerthank you. And how do you create an instance of a room db in an intellij desktop only project?
Anyone got room doesnt work on release setup on desktop with .msi .. ??
Working on android studio
I hope to create a video about migrate from android project to kmp project
Already done
@@PhilippLackner I don't think that I missed a video for you, I mean if there is an existing android project, how to migrate its settings and configurations to be a kmp one
Hii Philipp.. KSP has generate source code but instantiateImpl() is not resolved in iOS SourceSet. But it is resolved in Android SourceSet. I couldn't figure out the root cause. I have checked generated build folder. I found the method in both iOS & Android generated files but am not getting why it is not resolved in iOS source set resulting in build failure. Please help us to resolve this.
Just launch the app, it'll work :)
@@PhilippLackner Thanks for responding. And thanks a lot for your contribution towards Android Community..
If some one from subscriber knows how to login to account on pl-coding, please reply. I am not able to see a way to login on pl-coding. I want to access course that I enrolled for.
How to login to my account on pl-coding website?
After the purchase you got an email with instructions to set a password on Memberspot. Then you just need to log in there with the link in the email :)
@@PhilippLackner Thanks for reply! I was searching in emails by your name. Now I got it.
Struggling to use it with Koin
Use SqlDelight
I would like to see compose-ios, using a simple Android and ios webview
Already have a 3h course here on RUclips :)
If you want to show off multiplatform, it is a bad idea to do so on Android. We already know it works in Android, there is no point
Why not use mongodb?
Coisa de mongol
Because its trash for most use cases
It was my mistake to implement realm years ago
For now, there are a new way to define ksp dependency(also recommended by Jetbrains)
```Kotlin
dependencies {
add("kspAndroid", libs.utils.db.room.compiler)
add("kspIosSimulatorArm64", libs.utils.db.room.compiler)
add("kspIosX64", libs.utils.db.room.compiler)
add("kspIosArm64", libs.utils.db.room.compiler)
add("kspJvm", libs.utils.db.room.compiler)
}
```
Hi, do you have example project with these new upadtes? I cant manage how to set up this all ://
@@maciejnowak2120
*** In build.gradle.kts replace:
dependencies {
ksp(libs.room.compiler)
}
by
dependencies {
add("kspAndroid", libs.room.compiler)
add("kspIosSimulatorArm64", libs.room.compiler)
add("kspIosX64", libs.room.compiler)
add("kspIosArm64", libs.room.compiler)
}
*** In PeopleDatabase.kt replace:
@Database(
entities = [Person::class],
version = 1
)
abstract class PeopleDatabase: RoomDatabase() {
abstract fun peopleDao(): PeopleDao
}
by
@ConstructedBy(PeopleDatabaseConstructor::class)
@Database(
entities = [Person::class],
version = 1
)
abstract class PeopleDatabase: RoomDatabase() {
abstract fun peopleDao(): PeopleDao
}
// The Room compiler generates the `actual` implementations.
@Suppress("NO_ACTUAL_FOR_EXPECT")
expect object PeopleDatabaseConstructor : RoomDatabaseConstructor {
override fun initialize(): PeopleDatabase
}
*** In getPeopleDatabaseImpl.kt in isoMaon package comment out this line:
factory = { PeopleDatabase::class.instantiateImpl() }