cashapp / multiplatform-paging

A library that packages AndroidX Paging for Kotlin/Multiplatform.
Apache License 2.0
506 stars 20 forks source link

Could not find "org.jetbrains.compose.collection-internal:collection" when running Task :composeApp:compileKotlinIosSimulatorArm64 #251

Open hafiz013 opened 2 months ago

hafiz013 commented 2 months ago

Below here details error:

> Task :composeApp:compileKotlinIosSimulatorArm64 FAILED
error: Could not find "org.jetbrains.compose.collection-internal:collection" in [/Users/mohdhafiz/Downloads/AssetManagementSystem, /Users/mohdhafiz/.konan/klib, /Users/mohdhafiz/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.21/klib/common, /Users/mohdhafiz/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.21/klib/platform/ios_simulator_arm64]
error: Compilation finished with errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':composeApp:compileKotlinIosSimulatorArm64'.
> Compilation finished with errors

Below here my setup:


     commonMain.dependencies {
        implementation(libs.paging.compose.common)
     }
}```

inside lib.versions.toml:
paging-compose-common = { module = "app.cash.paging:paging-compose-common", version.ref = "3.3.0-alpha02-0.5.1" }

Sample setup code:
```open class ResultPagingSource<T : Any>(private val pagingData: suspend (page: Int, pageSize: Int) -> ResultWrapper<List<T>>) :
    PagingSource<Int, T>() {

    override fun getRefreshKey(state: PagingState<Int, T>): Int? = null

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, T> =
        (params.key ?: 1).let { _page ->
            try {
                pagingData(_page, params.loadSize)
                    .run {
                        when(this){
                            is ResultWrapper.Success ->{
                                LoadResult.Page(
                                    data = value,
                                    /* no previous pagination int as page */
                                    prevKey = _page.takeIf { it > 1 }?.dec(),
                                    /* no pagination if no results found else next page as +1 */
                                    nextKey = _page.takeIf { value.size >= params.loadSize }?.inc()
                                )
                            }
                            is ResultWrapper.NetworkError ->{
                                LoadResult.Error(this.throwable)
                            }
                            is ResultWrapper.Failure ->{
                                LoadResult.Error(Throwable(this.error?.message ?: ""))
                            }
                        }
                    }
            } catch (e: Exception) {
                LoadResult.Error(e)
            }
        }
}```

```fun getCategoryContent(category: String, staffId: String,
                          position: String, currentPage: Int): Flow<PagingData<ItemsCategory>> = Pager(
        config = PagingConfig(pageSize = 10, initialLoadSize = 10, enablePlaceholders = true),
        pagingSourceFactory = {
            ResultPagingSource { _, _ ->
                getCategoryContentList(category, staffId, position, currentPage).map { it.listOfItemsCategory }
            }
        }
    ).flow
    private suspend fun getCategoryContentList(category: String, staffId: String,
                                       position: String, currentPage: Int): ResultWrapper<ContentCategoryResponse>{
        return try {
            val assetPageResponse = client.request {
                url("categorySpecific")
                setBody(ContentCategoryRequest(category, staffId, position, currentPage))
            }
            if (assetPageResponse.status.isSuccess()) {
                ResultWrapper.Success(
                    assetPageResponse.body<ContentCategoryResponse>(),
                    assetPageResponse.status.value
                )
            } else {
                ResultWrapper.Failure(
                    assetPageResponse.status.value,
                    assetPageResponse.body<APIErrorResponse>()
                )
            }
        } catch (e: Exception) {
            ResultWrapper.NetworkError(e)
        }
    }```

why this happen on folder shared?