Trey
11/22/2023, 10:31 PMPablichjenkov
11/22/2023, 10:44 PMPablichjenkov
11/22/2023, 10:46 PMTrey
11/22/2023, 10:47 PMlistOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "ComposeApp"
isStatic = true
}
}
Trey
11/22/2023, 10:48 PMTrey
11/22/2023, 10:50 PMTrey
11/22/2023, 10:50 PMPablichjenkov
11/22/2023, 10:51 PMPablichjenkov
11/22/2023, 10:53 PMPablichjenkov
11/22/2023, 10:56 PMTrey
11/22/2023, 10:57 PMPablichjenkov
11/22/2023, 10:58 PMPablichjenkov
11/22/2023, 10:59 PMTrey
11/22/2023, 10:59 PMPablichjenkov
11/22/2023, 11:01 PMPablichjenkov
11/22/2023, 11:03 PMPablichjenkov
11/22/2023, 11:03 PMTrey
11/22/2023, 11:04 PMPablichjenkov
11/22/2023, 11:05 PMPablichjenkov
11/22/2023, 11:06 PMJoel Denke
11/23/2023, 9:04 PMMofe Ejegi
11/24/2023, 4:59 PMTrey
11/24/2023, 5:01 PMPablichjenkov
11/24/2023, 5:25 PMMofe Ejegi
12/06/2023, 1:03 AMTrey
12/06/2023, 1:19 AMPablichjenkov
12/06/2023, 1:48 AMsingle<NetworkHelper> { AndroidNetworkHelper(androidContext()) }
and in iOS
single<NetworkHelper> { get<IosApplicationComponent>().networkHelper }
why not bellow line in iOS
single<NetworkHelper> { NetworkHelper() }
Just to have the same in both platforms so the reader won't question about this subtle difference.Mofe Ejegi
12/06/2023, 4:37 PMApplicationComponent
serve as the bridge for platform dependencies.
In this case, I'm attempting to provide the NetworkHelper
by getting it from the IosApplicationComponent
since the iosMain
source set is unaware of the IosNetworkHelper()
class implemented in swift in the iosApp
target.
I also did something similar when passing userDefaults
from iOS for MultiplatformSettings
single<Settings> { NSUserDefaultsSettings(get<IosApplicationComponent>().userDefaults) }
(NSUserDefaults
is already part of Kotlin Native so this wasn't entirely necessary)
I understand why it raises eyebrows though, and of course, I'll attempt exploring some other way of passing dependencies to be more consistent.Joel Denke
12/06/2023, 4:41 PMMofe Ejegi
12/06/2023, 4:44 PMsingle<NetworkHelper> { get<AndroidApplicationComponent>().networkHelper }
However, the new KMP Compose UI template sorta merged the androidApp
module into the androidMain
source set and called it composeApp
, so I simply just traced my steps back and made it all straightforward on the Android side.Mofe Ejegi
12/06/2023, 4:52 PMCredentialsManager
doesn't explicitly expose the Activity result flow to us, rather, it uses a suspending credentialManager.getCredential()
function to retrieve the auth details. Under the hood, it launches a HiddenActivity
which houses the bottom sheet dialog.
On iOS, it just launches the usual modal webview and uses:
.onOpenURL { url in
GIDSignIn.sharedInstance.handle(url)
}
In the SwiftUI root scene.
Lastly, I'm using a GoogleAuthProvider
interface which I created, on both platforms to streamline the logic.
interface GoogleAuthProvider {
suspend fun login(
context: PlatformContext,
onAuthResult: (GoogleAuthResult) -> Unit,
onAuthError: (Throwable) -> Unit,
)
suspend fun logout()
}
I actually learned loads of new tips while implementing this and I'm eager to share it.Joel Denke
12/06/2023, 4:58 PMJoel Denke
12/06/2023, 5:02 PMJoel Denke
12/06/2023, 5:03 PMMofe Ejegi
12/06/2023, 5:04 PMJoel Denke
12/06/2023, 5:04 PMJoel Denke
12/06/2023, 5:05 PMJoel Denke
12/06/2023, 5:05 PMJoel Denke
12/06/2023, 5:06 PMMofe Ejegi
12/06/2023, 5:06 PMMofe Ejegi
12/06/2023, 5:07 PMJoel Denke
12/06/2023, 5:07 PMJoel Denke
12/06/2023, 5:07 PMJoel Denke
12/06/2023, 5:09 PMJoel Denke
12/06/2023, 5:09 PMJoel Denke
12/06/2023, 5:10 PMJoel Denke
12/06/2023, 5:11 PMJoel Denke
12/06/2023, 5:11 PMJoel Denke
12/06/2023, 5:14 PMJoel Denke
12/06/2023, 5:15 PMPablichjenkov
12/06/2023, 7:30 PMAndroidApplicationComponent(). networkHelper
just to be symmetric o both platforms but just personal preference.
Looking forward to that second part π―π₯π