| Wofür | Bibliothek | Source Set |
|---|---|---|
| Navigation 3 | org.jetbrains.androidx.navigation3:navigation3-ui | commonMain |
| Serialization | kotlinx-serialization-core + Plugin | commonMain |
| HTTP | Ktor Client, Content Negotiation, JSON | commonMain |
| HTTP-Engine | ktor-client-okhttp / ktor-client-darwin | androidMain / iosMain |
| ViewModel, Lifecycle | schon vom Wizard eingebunden | commonMain |
model/, data/ und ui/ (mit ui/theme) aus schritt-10 nach
shared/src/commonMain/kotlin/… kopierenpackage und Imports ersetzen (weatherandroidtif24 → weatherkmptif24)App() zeigt die Wetter-App@Composable
fun App() {
WeatherAndroidTIF24Theme {
WeatherApp()
}
}Alles, was es nur unter Android oder auf der JVM gibt:
| Stelle | Ersatz |
|---|---|
HttpClient(OkHttp) | HttpClient { … }, Engine pro Plattform |
java.io.IOException | kotlinx.io.IOException |
"%.2f".format(…) | String-Template |
| Dynamic Color im Theme | feste Farben |
Preview mit uiMode | Theme mit darkTheme = true |
private val navConfig = SavedStateConfiguration {
serializersModule = SerializersModule {
polymorphic(NavKey::class) {
subclass(CityList::class, CityList.serializer())
subclass(CityWeather::class, CityWeather.serializer())
}
}
}
val backStack = rememberNavBackStack(navConfig, CityList)Unter iOS stürzt die App beim Start ab:
UnsupportedOperationException: `Factory.create(String, CreationExtras)` is not implemented.// WeatherApp
val weatherViewModel = viewModel { WeatherViewModel() }
// WeatherScreen (Default-Parameter)
viewModel: WeatherViewModel = viewModel { WeatherViewModel() },