File tree Expand file tree Collapse file tree 3 files changed +14
-29
lines changed
src/iosMain/kotlin/com/example/fruitties/di/viewmodel Expand file tree Collapse file tree 3 files changed +14
-29
lines changed Original file line number Diff line number Diff line change @@ -3,16 +3,15 @@ import shared
3
3
4
4
/// A ViewModelStoreOwner specifically for iOS.
5
5
/// This is used with from iOS with Kotlin Multiplatform (KMP).
6
- class IOSViewModelStoreOwner : ObservableObject , SwiftViewModelStoreOwner {
6
+ class IOSViewModelStoreOwner : ObservableObject , ViewModelStoreOwner {
7
7
8
- var viewModelStore : Lifecycle_viewmodelViewModelStore =
9
- Lifecycle_viewmodelViewModelStore ( )
8
+ var viewModelStore = ViewModelStore ( )
10
9
11
10
/// This function allows retrieving the androidx ViewModel from the store.
12
- func viewModel< T: Lifecycle_viewmodelViewModel > (
11
+ func viewModel< T: ViewModel > (
13
12
key: String ? = nil ,
14
- factory: Lifecycle_viewmodelViewModelProviderFactory ,
15
- extras: Lifecycle_viewmodelCreationExtras ? = nil
13
+ factory: ViewModelProviderFactory ,
14
+ extras: CreationExtras ? = nil
16
15
) -> T {
17
16
do {
18
17
return try viewModelStore. getViewModel (
Original file line number Diff line number Diff line change @@ -50,26 +50,17 @@ kotlin {
50
50
// A step-by-step guide on how to include this library in an XCode
51
51
// project can be found here:
52
52
// https://developer.android.com/kotlin/multiplatform/migrate
53
- val xcfName = " shared"
54
53
55
- iosX64 {
56
- binaries.framework {
57
- baseName = xcfName
54
+ listOf (
55
+ iosX64(),
56
+ iosArm64(),
57
+ iosSimulatorArm64()
58
+ ).forEach {
59
+ it.binaries.framework {
60
+ export(libs.androidx.lifecycle.viewmodel)
61
+ baseName = " shared"
58
62
}
59
63
}
60
-
61
- iosArm64 {
62
- binaries.framework {
63
- baseName = xcfName
64
- }
65
- }
66
-
67
- iosSimulatorArm64 {
68
- binaries.framework {
69
- baseName = xcfName
70
- }
71
- }
72
-
73
64
// Source set declarations.
74
65
// Declaring a target automatically creates a source set with the same name. By default, the
75
66
// Kotlin Gradle Plugin creates additional source sets that depend on each other, since it is
@@ -90,7 +81,7 @@ kotlin {
90
81
implementation(libs.ktor.client.content.negotiation)
91
82
implementation(libs.ktor.serialization.kotlinx.json)
92
83
implementation(libs.skie.annotations)
93
- implementation (libs.androidx.lifecycle.viewmodel)
84
+ api (libs.androidx.lifecycle.viewmodel)
94
85
implementation(libs.androidx.paging.common)
95
86
implementation(libs.androidx.room.runtime)
96
87
implementation(libs.sqlite.bundled)
Original file line number Diff line number Diff line change @@ -31,8 +31,3 @@ fun ViewModelStore.getViewModel(
31
31
return key?.let { provider[key, vmClass] } ? : provider[vmClass]
32
32
}
33
33
34
- /* *
35
- * The ViewModelStoreOwner isn't used anywhere in the project, therefore it's not visible for Swift by default.
36
- */
37
- @Suppress(" unused" )
38
- interface SwiftViewModelStoreOwner : ViewModelStoreOwner
You can’t perform that action at this time.
0 commit comments