Hey guys, I do have an issue when building on ios ...
# multiplatform
g
Hey guys, I do have an issue when building on ios with CMP. Basically it seems like Res files are failing to load either drawables or strings. The issue I’m getting is on composeAppembedAndSignAppleFrameworkForXcode and is org.jetbrains.kotlin.util.FileAnalysisException: Somewhere in file /repository/project_name/composeApp/build/generated/compose/resourceGenerator/kotlin/commonMainResourceAccessors/project_name/composeapp/generated/resources/Drawable0.commonMain.kt: org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type. It has been building fine for the last few days but it started giving me this issue from one day to another. What I’ve tried so far was: • Clean project and rebuild from Intellij Idea • Clean the project from xCode • And then tried for the terminal with:
Copy code
./gradlew --stop
./gradlew clean
rm -rf composeApp/build/
rm -rf .gradle/
rm -rf ~/.gradle/caches/
And build back but nothing has been working. If someone have any tip on how to try to fix this let me know. Thanks.
a
Hi @Giuseppe Joshua Falcone, could you please share the content of the
Drawable0.commonMain.kt
file at the time of the error? you can strip away resources names and paths or any other sensitive data, or you can share it with us JetBrains through a YouTrack ticket with limited visibility, thank you!
g
Hi @Alexandru Resiga, thanks for replying, seemed like the issue was relative to the kotlin version:
Copy code
kotlin = "2.1.21"
The content of the drawable was just the base Compose logo that is given when creating the project. Content of Drawable0.commonMain.kt was:
Copy code
@file:OptIn(InternalResourceApi::class)

package myapp.composeapp.generated.resources

import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.ResourceItem

private const val MD: String = "composeResources/myapp.composeapp.generated.resources/"

internal val Res.drawable.compose_multiplatform: DrawableResource by lazy {
      DrawableResource("drawable:compose_multiplatform", setOf(
        ResourceItem(setOf(), "${MD}drawable/compose-multiplatform.xml", -1, -1),
      ))
    }

@InternalResourceApi
internal fun _collectCommonMainDrawable0Resources(map: MutableMap<String, DrawableResource>) {
  map.put("compose_multiplatform", Res.drawable.compose_multiplatform)
}
Same for the content of the strings.xml was just
Copy code
<resources>
    <string name="app_name">App Name</string>
</resources>
Content of the String0.commonMain.kt was
Copy code
@file:OptIn(InternalResourceApi::class)

package myapp.composeapp.generated.resources

import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.ResourceItem
import org.jetbrains.compose.resources.StringResource

private const val MD: String = "composeResources/myapp.composeapp.generated.resources/"

internal val Res.string.app_name: StringResource by lazy {
      StringResource("string:app_name", "app_name", setOf(
        ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 10, 24),
      ))
    }

@InternalResourceApi
internal fun _collectCommonMainString0Resources(map: MutableMap<String, StringResource>) {
  map.put("app_name", Res.string.app_name)
}
But the issue that the compiler was giving was including all the fils in my proj printed as following:
Copy code
* Source files: Drawable0.commonMain.kt, String0.commonMain.kt, ExpectResourceCollectors.kt, Res.kt, ActualResourceCollectors.kt, MyApp.kt, MyService.kt, MyServiceImpl.kt, MyObjDetail.kt, MyRepositoryImpl.kt, MyKoin.kt, ServiceModule.kt, NetworkModule.kt, RepositoryModule.kt, UseCaseModule.kt, ViewModelModule.kt, MyRepository.kt, MyUseCase.kt, HttpClient.kt, MyUiState.kt, MyViewModel.kt, NavigationScreen.kt, Error.kt, Network.kt, NetworkError.kt, PlatformUtil.kt, MainViewController.kt, NetworkModule.ios.kt, PlatformUtil.ios.kt
 * Compiler version: 2.1.21
 * Output kind: LIBRARY
Seems like everything works as expected with version 2.1.20