I want to implement @Lenses data class in anotherM...
# fritz2
s
I want to implement @Lenses data class in anotherMain rather than in commonMain. How can I do that. Lenses data classes are not being recongnized outside of commonMain automatically.
h
Why would you want to do this?
s
I have an ios app on this project as well and the fritz2 core library in the commonMain is not recognized when I try to run iosApp
I am just testing waters to see if i can do fritz2, ios and android all in same project
h
I think something in your setup is invalid, because
commonMain
is supposed to be accessible from Android, JVM, JS & Native. 😮
s
No I checked. When i try to run iosApp it cannot recognize @Lenses model I have in the commonMain. But when I run fritz it works fine.
I was told to try something like this:
Copy code
kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies { }
        }
        val fritzMain by creating {
            dependsOn(commonMain)
            dependencies {
                implementation("dev.fritz2:core:$fritz2Version")
            }
        }
        val jvmMain by getting {
            dependsOn(fritzMain)
            dependencies { }
        }
        val jsMain by getting {
            dependsOn(fritzMain)
            dependencies { }
        }
        val iosMain by getting {
            dependsOn(commonMain)
            dependencies { }
        }
    }
}
which works great but
@Lenses
does not work in
FritzMain
. Otherwise everything works great.
h
Huh, I’ve never done it like this. And actually their own “project-template” is done the following way;
Copy code
sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("dev.fritz2:core:$fritz2Version")
                // implementation("dev.fritz2:headless:$fritz2Version") // optional
            }
        }
        val jvmMain by getting {
            dependencies {
            }
        }
        val jsMain by getting {
            dependencies {
            }
        }
    }
with some extras, like
Copy code
dependencies {
    add("kspMetadata", "dev.fritz2:lenses-annotation-processor:$fritz2Version")
}
see https://github.com/jwstegemann/fritz2-template/blob/master/build.gradle.kts
s
I have seen this. This does not include ios and android mains
without that, I cannot build for Ios and Android.
h
I’d expect you’d just add them without any “dependency” on commonMain. But I guess you’ve tried that already, sorry cannot help you further
s
Yeah already tried that but need commonMain dependency unfortunately. Thanks anyways!