https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
c

Charles Prado

05/19/2021, 11:45 AM
Hello everyone! Someone here already had problems with XCode SwiftUI previews while using KMM? The preview updates are paused every time for me, it seems that it's only happening in KMM projects. I already set all my scripts to run only on install but that doesn't solve the problem.
r

russhwolf

05/19/2021, 12:54 PM
There's a known issue around static frameworks, such as cocoapods plugin creates by default. Try this https://github.com/JetBrains/kotlin-native/issues/3059#issuecomment-577041551
c

Charles Prado

05/20/2021, 11:25 AM
tks for that @russhwolf
w

wuseal

06/21/2021, 11:13 AM
@Charles Prado The second answer solve the same problem('The preview updates are paused every time') for me https://stackoverflow.com/questions/58490010/swiftui-automatic-preview-updating-paused-always Now my project could be automatic update preview ui now when using KMM with dynamic framework(by cocoapods plugin)
Copy code
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        binaries.withType<org.jetbrains.kotlin.gradle.plugin.mpp.Framework> {
            isStatic = buildForDevice
        }
    }
Configs in Xcode for KMM lib
Copy code
noPodspec()
val podFile = file("kmmlib.podspec")
podFile.writeText(
    podFile.readText().replace(
        oldValue = "spec.static_framework         = ${buildForDevice.not()}",
        newValue = "spec.static_framework         = $buildForDevice"
    )
)
c

Charles Prado

06/21/2021, 11:44 AM
Hey @wuseal, I ended up applying this solution too. Fixed for me as well. Tks 🙂
6 Views