I'm not sure if anyone has ran into this. I curren...
# compose-ios
t
I'm not sure if anyone has ran into this. I currently ran into issues w previewing compose in
shared
(using our current template). 1 - If I tried to add
Copy code
val commonMain by getting {
            dependencies {
                ...
                implementation(compose.uiTooling)
                implementation(compose.preview)
            }
        }
(where the
resources
folder currently located:
shared/commonMain/resources/...
)
When sync w gradle, I got error:
A problem occurred configuring project ':shared'.
> Could not resolve all dependencies for configuration 'sharediosArm64CompileKlibraries'.
> Could not resolve org.jetbrains.compose.uiui tooling1.4.0.
Required by:
project :shared
> No matching variant of org.jetbrains.compose.uiui tooling1.4.0 was found. The consumer was configured to find a usage of 'kotlin-api' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64' but: ...
2 - I figured, probably I can only preview in Android-specific code, so I tried to specify in
androidMain
Copy code
val androidMain by getting {
            dependencies {
                ...
                implementation(compose.uiTooling)
                implementation(compose.preview)
            }
        }
Sync w gradle is ok, but then IDE didn't recognize the resources
Render problem: org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: icon/ic_google_logo.xml at layoutlib.internal.kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith ...
3 - So I tried in
androidApp
module and duplicate
resources
folder, but it still can't recognize. iOS/Android apps still compiled and ran normal, but just no preview (Not big deal, but I thought it may be better if I can preview in realtime in
shared
module w/o duplicating resources everywhere). Thanks a lot for your all times in advance.
1
a
Isn't the tooling only for Android and Deskotop?
o
Copy code
implementation(compose.preview)
this preview is currently available only for desktop. android has its own preview from jetpack compose. other platforms don't have a preview for now.
Isn't the tooling only for Android and Deskotop?
That's right - https://github.com/JetBrains/compose-multiplatform-core/blob/jb-main/compose/ui/ui-tooling/build.gradle#L68
j
Just do check as struggle with similar, if adding androidx compose preview to android but want to have @Preview blocks in commonMain I cant do that? Or how does that work? Both IDE preview and sync to emulator/device. Whats working and when?
o
the preview won't work in commonMain. desktop @Preview works in destkopMain (with Compose MPP IDE plugin installed) and android (jetpack compose) preview should work in androidMain
c
Is there anyway to enable Preview in common @Oleksandr Karpovich [JB]? This would improve and streamline production a lot, the burden of visiting another platform or simply building to validate your designs is a little odd. Even having some specific platform preview would be nice already, be it desktop or android
What I meant is more in the direction of feasibility
o
Sorry, just noticed the message. Unfortunately, there is no way to have preview in commonMain for now unless your module is desktop-only. There is an internal discussion about how to approach it, so we recognise it as a pain point.
👌 2
c
Thank you for the response
188 Views