Hi Arrow team, I'm having trouble to setup KSP for...
# arrow
i
Hi Arrow team, I'm having trouble to setup KSP for Optics on a Kotlin Compose Multiplatform project (Android + Desktop). I'm 100% doing something wrong but wanted to save some time and ask for advice or a sample project setup link. Here's my code: https://github.com/Ivy-Apps/ivy-wallet/tree/multiplatform What I want to achieve: • Have a
:common
module containing all the data classes for the app and have Lens generated for them via
@optics
- it worked perfectly and the setup was quite easy when it was Android only app but now I got stuck • Preferably, @optics to work on all modules but it'll be sufficient just for the
:common
one. • To see the generated code in my IDEs (not red) in other modules, too - I use both Android Studio + Idea P.S. I tried a lot of things but eventually removed the KSP stuff because I couldn't get the project to compile.
If this isn't easy, my best workaround is to use ChatGTP + Copilot to generate the Lens for me 😄 But hopefully I won't resort to that
With my current setup I get conflicting declarations error:
Copy code
e: file:///home/iliyan/work/repo/ivy-wallet/Ivy-Wallet/common/build/generated/ksp/android/androidDebug/kotlin/ivy/common/demo/Address__Optics.kt:8:53 Conflicting declarations: public val ivy.common.demo.Address.Companion.iso: Iso<Address, Pair<String, String>> /* = PIso<Address, Address, Pair<String, String>, Pair<String, String>> */, public val ivy.common.demo.Person.Companion.iso: Iso<Person, Pair<String, Address>> /* = PIso<Person, Person, Pair<String, Address>, Pair<String, Address>> */, public val ivy.common.demo.Address.Companion.iso: Iso<Address, Pair<String, String>> /* = PIso<Address, Address, Pair<String, String>, Pair<String, String>> */, public val ivy.common.demo.Person.Companion.iso: Iso<Person, Pair<String, Address>> /* = PIso<Person, Person, Pair<String, Address>, Pair<String, Address>> */
e: file:///home/iliyan/work/repo/ivy-wallet/Ivy-Wallet/common/build/generated/ksp/android/androidDebug/kotlin/ivy/common/demo/Address__Optics.kt:13:53 Conflicting declarations: public val Address.Companion.country: Lens<Address, String> /* = PLens<Address, Address, String, String> */, public val <S> Iso<S, Address> /* = PIso<S, S, Address, Address> */.country: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Lens<S, Address> /* = PLens<S, S, Address, Address> */.country: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Optional<S, Address> /* = POptional<S, S, Address, Address> */.country: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Prism<S, Address> /* = PPrism<S, S, Address, Address> */.country: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Getter<S, Address>.country: Getter<S, String>, public val <S> Setter<S, Address> /* = PSetter<S, S, Address, Address> */.country: Setter<S, String> /* = PSetter<S, S, String, String> */, public val <S> Traversal<S, Address> /* = PTraversal<S, S, Address, Address> */.country: Traversal<S, String> /* = PTraversal<S, S, String, String> */, public val <S> Fold<S, Address>.country: Fold<S, String>, public val <S> Every<S, Address> /* = PEvery<S, S, Address, Address> */.country: Every<S, String> /* = PEvery<S, S, String, String> */, public val Address.Companion.country: Lens<Address, String> /* = PLens<Address, Address, String, String> */, public val <S> Iso<S, Address> /* = PIso<S, S, Address, Address> */.country: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Lens<S, Address> /* = PLens<S, S, Address, Address> */.country: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Optional<S, Address> /* = POptional<S, S, Address, Address> */.country: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Prism<S, Address> /* = PPrism<S, S, Address, Address> */.country: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Getter<S, Address>.country: Getter<S, String>, public val <S> Setter<S, Address> /* = PSetter<S, S, Address, Address> */.country: Setter<S, String> /* = PSetter<S, S, String, String> */, public val <S> Traversal<S, Address> /* = PTraversal<S, S, Address, Address> */.country: Traversal<S, String> /* = PTraversal<S, S, String, String> */, public val <S> Fold<S, Address>.country: Fold<S, String>, public val <S> Every<S, Address> /* = PEvery<S, S, Address, Address> */.country: Every<S, String> /* = PEvery<S, S, String, String> */
e: file:///home/iliyan/work/repo/ivy-wallet/Ivy-Wallet/common/build/generated/ksp/android/androidDebug/kotlin/ivy/common/demo/Address__Optics.kt:18:53 Conflicting declarations: public val Address.Companion.city: Lens<Address, String> /* = PLens<Address, Address, String, String> */, public val <S> Iso<S, Address> /* = PIso<S, S, Address, Address> */.city: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Lens<S, Address> /* = PLens<S, S, Address, Address> */.city: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Optional<S, Address> /* = POptional<S, S, Address, Address> */.city: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Prism<S, Address> /* = PPrism<S, S, Address, Address> */.city: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Getter<S, Address>.city: Getter<S, String>, public val <S> Setter<S, Address> /* = PSetter<S, S, Address, Address> */.city: Setter<S, String> /* = PSetter<S, S, String, String> */, public val <S> Traversal<S, Address> /* = PTraversal<S, S, Address, Address> */.city: Traversal<S, String> /* = PTraversal<S, S, String, String> */, public val <S> Fold<S, Address>.city: Fold<S, String>, public val <S> Every<S, Address> /* = PEvery<S, S, Address, Address> */.city: Every<S, String> /* = PEvery<S, S, String, String> */, public val Address.Companion.city: Lens<Address, String> /* = PLens<Address, Address, String, String> */, public val <S> Iso<S, Address> /* = PIso<S, S, Address, Address> */.city: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Lens<S, Address> /* = PLens<S, S, Address, Address> */.city: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Optional<S, Address> /* = POptional<S, S, Address, Address> */.city: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Prism<S, Address> /* = PPrism<S, S, Address, Address> */.city: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Getter<S, Address>.city: Getter<S, String>, public val <S> Setter<S, Address> /* = PSetter<S, S, Address, Address> */.city: Setter<S, String> /* = PSetter<S, S, String, String> */, public val <S> Traversal<S, Address> /* = PTraversal<S, S, Address, Address> */.city: Traversal<S, String> /* = PTraversal<S, S, String, String> */, public val <S> Fold<S, Address>.city: Fold<S, String>, public val <S> Every<S, Address> /* = PEvery<S, S, Address, Address> */.city: Every<S, String> /* = PEvery<S, S, String, String> */
e: file:///home/iliyan/work/repo/ivy-wallet/Ivy-Wallet/common/build/generated/ksp/android/androidDebug/kotlin/ivy/common/demo/Address__Optics.kt:26:68 Conflicting declarations: public val Address.Companion.country: Lens<Address, String> /* = PLens<Address, Address, String, String> */, public val <S> Iso<S, Address> /* = PIso<S, S, Address, Address> */.country: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Lens<S, Address> /* = PLens<S, S, Address, Address> */.country: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Optional<S, Address> /* = POptional<S, S, Address, Address> */.country: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Prism<S, Address> /* = PPrism<S, S, Address, Address> */.country: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Getter<S, Address>.country: Getter<S, String>, public val <S> Setter<S, Address> /* = PSetter<S, S, Address, Address> */.country: Setter<S, String> /* = PSetter<S, S, String, String> */, public val <S> Traversal<S, Address> /* = PTraversal<S, S, Address, Address> */.country: Traversal<S, String> /* = PTraversal<S, S, String, String> */, public val <S> Fold<S, Address>.country: Fold<S, String>, public val <S> Every<S, Address> /* = PEvery<S, S, Address, Address> */.country: Every<S, String> /* = PEvery<S, S, String, String> */, public val Address.Companion.country: Lens<Address, String> /* = PLens<Address, Address, String, String> */, public val <S> Iso<S, Address> /* = PIso<S, S, Address, Address> */.country: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Lens<S, Address> /* = PLens<S, S, Address, Address> */.country: Lens<S, String> /* = PLens<S, S, String, String> */, public val <S> Optional<S, Address> /* = POptional<S, S, Address, Address> */.country: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Prism<S, Address> /* = PPrism<S, S, Address, Address> */.country: Optional<S, String> /* = POptional<S, S, String, String> */, public val <S> Getter<S, Address>.country: Getter<S, String>, public val <S> Setter<S, Address> /* = PSetter<S, S, Address, Address> */.country: Setter<S, String> /* = PSetter<S, S, String, String> */, public val <S> Traversal<S, Address> /* = PTraversal<S, S, Address, Address> */.country: Traversal<S, String> /* = PTraversal<S, S, String, String> */, public val <S> Fold<S, Address>.country: Fold<S, String>, public val <S> Every<S, Address> /* = PEvery<S, S, Address, Address> */.country: Every<S, String> /* = PEvery<S, S, String, String> */
e: file:///home/iliyan/work/repo/ivy-wallet/Ivy-Wallet/common/build/generated/ksp/android/androidDebug/kotlin/ivy/common/demo/Address__Optics.kt:26:159 Overload resolution ambiguity:
a
was the code using `expect`/`actual`?
i