Sunil Kumar
06/21/2023, 7:40 AMval lifecycle = LifecycleRegistry()
val rootComponentContext = DefaultComponentContext(lifecycle = lifecycle)
val root = DefaultRootComponent(
componentContext = rootComponentContext
)
MaterialTheme {
Surface(
modifier = Modifier
.fillMaxSize()
) {
RootContent(component = root)
}
}
Sunil Kumar
06/21/2023, 7:42 AMSunil Kumar
06/21/2023, 7:52 AMArkadii Ivanov
06/21/2023, 7:58 AMSunil Kumar
06/21/2023, 8:12 AMArkadii Ivanov
06/21/2023, 8:13 AMArkadii Ivanov
06/21/2023, 8:15 AMSunil Kumar
06/21/2023, 9:13 AMArkadii Ivanov
06/21/2023, 9:19 AMSunil Kumar
06/21/2023, 9:30 AMArkadii Ivanov
06/21/2023, 9:31 AMSunil Kumar
07/05/2023, 5:36 AM@main
struct iOSApp: App {
var body: some Scene {
WindowGroup {
GeometryReader { geo in
ComposeViewControllerToSwiftUI(
topSafeArea: Float(<http://geo.safeAreaInsets.top|geo.safeAreaInsets.top>),
bottomSafeArea: Float(geo.safeAreaInsets.bottom)
)
.ignoresSafeArea()
}
}
}
}
struct ComposeViewControllerToSwiftUI: UIViewControllerRepresentable {
private let topSafeArea: Float
private let bottomSafeArea: Float
init(topSafeArea: Float, bottomSafeArea: Float) {
self.topSafeArea = topSafeArea
self.bottomSafeArea = bottomSafeArea
}
func makeUIViewController(context: Context) -> UIViewController {
return Main_iosKt.MainViewController(
topSafeArea: topSafeArea,
bottomSafeArea: bottomSafeArea
)
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}
Calling the Main_iosKt.MainViewController in makeUIViewController.
ANd this MainViewController is my entry point in isoMain module of kmm
@OptIn(ExperimentalDecomposeApi::class)
fun MainViewController(
topSafeArea: Float,
bottomSafeArea: Float
): UIViewController {
return ComposeUIViewController {
val density = LocalDensity.current
val topSafeAreaDp = with(density) { topSafeArea.toDp() }
val bottomSafeAreaDp = with(density) { bottomSafeArea.toDp() }
val safeArea = PaddingValues(top = topSafeAreaDp + 32.dp/*, bottom = bottomSafeAreaDp*/)
val lifecycle = LifecycleRegistry()
val rootComponentContext = DefaultComponentContext(lifecycle = lifecycle)
val root = RootComponentImpl(
componentContext = rootComponentContext
)
MaterialTheme {
Surface(
modifier = Modifier
.fillMaxSize()
//.padding(safeArea),
) {
RootContent(component = root)
}
}
}
}
But according to your recommendation, how i will integrate that main() method from your sample in xcode ios project :
fun main() {
val args = emptyArray<String>()
memScoped {
val argc = args.size + 1
val argv = (arrayOf("skikoApp") + args).map { it.cstr.ptr }.toCValues()
autoreleasepool {
UIApplicationMain(argc, argv, null, NSStringFromClass(SkikoAppDelegate))
}
}
}
this one?Arkadii Ivanov
07/05/2023, 6:19 AMSunil Kumar
07/05/2023, 6:22 AMArkadii Ivanov
07/05/2023, 6:22 AMArkadii Ivanov
07/05/2023, 6:22 AMSunil Kumar
07/05/2023, 6:23 AMe: /Users/sunil/AndroidStudioProjects/ComposeInstagramCloneMultiplatform/shared/build.gradle.kts:3:27: Symbol is declared in module 'jdk.management.agent' which does not export package 'jdk.internal.agent'
I think its using wrong export method here, its importing this line :
import jdk.internal.agent.ConnectorAddressLink.export
this is my code in cocoapods:
cocoapods {
version = "1.0.0"
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
isStatic = true
}
export("com.arkivanov.decompose:decompose:$decomposeVersion")
extraSpecAttributes["resources"] =
"['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}
Arkadii Ivanov
07/05/2023, 6:25 AMSunil Kumar
07/05/2023, 6:28 AMArkadii Ivanov
07/05/2023, 6:29 AMSunil Kumar
07/05/2023, 6:30 AMSunil Kumar
07/05/2023, 6:50 AMExecution failed for task ':shared:linkPodDebugFrameworkIosSimulatorArm64'.
> Following dependencies exported in the podDebugFramework binary are not specified as API-dependencies of a corresponding source set:
Files: [/Users/sunil/.gradle/caches/modules-2/files-2.1/com.arkivanov.decompose/decompose-iossimulatorarm64/2.0.0-compose-experimental-beta-01/3cafd07f2ad9c583e3c9efb805c24423c1a13ab6/decompose.klib]
Files: [/Users/sunil/.gradle/caches/modules-2/files-2.1/com.arkivanov.essenty/lifecycle-iossimulatorarm64/1.1.0/c46194db2fd5b49be2f33029c1b7eeedab253b29/lifecycle.klib]
Files: [/Users/sunil/.gradle/caches/modules-2/files-2.1/com.arkivanov.essenty/utils-internal-iossimulatorarm64/1.1.0/1a1d5d21a37edf5489c833c9945d88a32adaef6d/utils-internal.klib]
Files: [/Users/sunil/.gradle/caches/modules-2/files-2.1/com.arkivanov.essenty/state-keeper-iossimulatorarm64/1.1.0/69d9828e944fc495433edb9537004902c2ba237c/state-keeper.klib]
Files: [/Users/sunil/.gradle/caches/modules-2/files-2.1/com.arkivanov.essenty/parcelable-iossimulatorarm64/1.1.0/ef6aef00d416366a8a6aa9492daf9cefa7c0e1f8/parcelable.klib]
Files: [/Users/sunil/.gradle/caches/modules-2/files-2.1/com.arkivanov.parcelize.darwin/runtime-iossimulatorarm64/0.1.4/46055c4c6ffbf1a823d3f4d0335aa9bf7db57c78/runtime.klib]
Files: [/Users/sunil/.gradle/caches/modules-2/files-2.1/com.arkivanov.essenty/instance-keeper-iossimulatorarm64/1.1.0/412479888f1c5b0b8b4e16ffd1125bc700fb8208/instance-keeper.klib]
Files: [/Users/sunil/.gradle/caches/modules-2/files-2.1/com.arkivanov.essenty/back-handler-iossimulatorarm64/1.1.0/83e021cb2ccc1fbbf23e79239f0d67ea814859c9/back-handler.klib]
Please add them in the API-dependencies and rerun the build.
SO which dependencies i need to export, currently i m exporting only decompose?Arkadii Ivanov
07/05/2023, 6:53 AMdecompose
and lifecycle
for now, and don't forget to specify those dependencies as api
.Sunil Kumar
07/05/2023, 6:53 AMSunil Kumar
07/05/2023, 6:54 AMSunil Kumar
07/05/2023, 6:54 AMSunil Kumar
07/05/2023, 6:56 AMval iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
dependencies {
api("com.arkivanov.decompose:decompose:$decomposeVersion")
api("com.arkivanov.essenty:lifecycle:$essentyVersion")
implementation("com.arkivanov.decompose:extensions-compose-jetbrains:$decomposeVersion")
}
}
it workedArkadii Ivanov
07/05/2023, 6:56 AMSunil Kumar
07/05/2023, 7:48 AMArkadii Ivanov
07/05/2023, 7:48 AMSunil Kumar
07/05/2023, 7:49 AM