Giter VIP home page Giter VIP logo

Comments (5)

terrakok avatar terrakok commented on July 22, 2024 1

CMP plugin is responsible for the resource merging on iOS

yes 👍
Android works because the resources are packed into aar libraries and there is no an additional logic

from compose-multiplatform.

terrakok avatar terrakok commented on July 22, 2024

@chrisbanes could you provide a small reproducer? I couldn't reproduce:
run ./gradlew :composeApp:iosSimulatorArm64Test
IosTestCheck.zip

from compose-multiplatform.

terrakok avatar terrakok commented on July 22, 2024
@OptIn(ExperimentalTestApi::class)
class ComposeTest {

    @OptIn(ExperimentalResourceApi::class)
    @Test
    fun simpleCheck() = runComposeUiTest {
        var bytes = ByteArray(0)
        setContent {
            val env = rememberResourceEnvironment()
            LaunchedEffect(true) {
                bytes = getDrawableResourceBytes(env, Res.drawable.ic_cyclone)
            }

            val resText = stringResource(Res.string.open_github)
            var txt by remember { mutableStateOf(resText) }
            Column {
                Text(
                    text = txt,
                    modifier = Modifier.testTag("t_text")
                )
                Button(
                    onClick = { txt += "." },
                    modifier = Modifier.testTag("t_button")
                ) {
                    Text("click me")
                }
            }
        }
        waitForIdle()
        assertEquals(943, bytes.size)

        onNodeWithTag("t_button").apply {
            repeat(3) { performClick() }
        }
        onNodeWithTag("t_text").assertTextEquals("Open github...")
    }
}

from compose-multiplatform.

chrisbanes avatar chrisbanes commented on July 22, 2024

Hmmm, I can repro this locally but I haven't tried making a reproducer yet. Here's the error:

org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: /foo/bar/shared/core/data/content/build/bin/iosSimulatorArm64/debugTest/compose-resources/composeResources/com.foo.bar/values/generated.commonMain.cvr
	at <global>.Data,(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:28)
	at <global>.Data,(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23)
	at <global>.Data,(/opt/buildAgent/work/3eb902016bd3838/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceReader.kt:5)
	at <global>.Data,(/opt/buildAgent/work/3eb902016bd3838/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.ios.kt:32)
	at <global>.Data,(/opt/buildAgent/work/3eb902016bd3838/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.ios.kt:17)
	at <global>.Data,(/opt/buildAgent/work/3eb902016bd3838/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceReader.kt:27)
	at <global>.Data,(/opt/buildAgent/work/3eb902016bd3838/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResourcesUtils.kt:30)
	at <global>.Data,(/opt/buildAgent/work/3eb902016bd3838/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResourcesUtils.kt:29)
	at <global>.Data,(/opt/buildAgent/work/3eb902016bd3838/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResourcesUtils.kt:27)

If I look in the build/bin/iosSimulatorArm64/debugTest folder, there is no compose-resources. The resources are from a different module which we depend on, so might be related to that. I'll keep digging.

from compose-multiplatform.

chrisbanes avatar chrisbanes commented on July 22, 2024

ugh just worked this out. The modules with failing tests did not have the CMP plugin applied on it 🤦.

Weirdly the Android unit tests worked as expected, but I assume the CMP plugin is responsible for the resource merging on iOS?

from compose-multiplatform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.