https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
j

Joel Denke

11/18/2023, 11:25 AM
Any nice guide how creating iOS app first time the right way in KMP/CMP 1.5.0+? Like what adjust in Xcode if needed or can generate iOS app integration with shared Gradle module. Often took the template project but can I generate this somehow myself without Xcode. Like in Fleet?
j

jamshedalamqaderi

11/18/2023, 11:27 AM
Generate a project from any site from two of these https://kmp.jetbrains.com/ https://terrakok.github.io/kmp-web-wizard/
🎉 1
j

Joel Denke

11/18/2023, 11:30 AM
Yeah but I cant tweak iOS settings in that. If want customize deep links, google play services, Swift ui interop, app delegates, and integrate into existing codebase. I have all my features complete but want restructure the entire iOS app using simplest solution can do with no Xcode interaction if possible. Also it changed a lot in KMP 1.5.0 where Wizards not provide the new way doing it?
Need multi modules, dont want cocoapods, ideally one shared module given it fits my structure with Android app module.
Also need vectors, fonts, locale strings etc.
j

jamshedalamqaderi

11/18/2023, 11:32 AM
kotlin still doesn't support swift interoperability. So, you can't use swift based library in kotlin/gradle. you need to implement them in iosApp then do something to access them in shared module
for resources you can use moko resources
j

Joel Denke

11/18/2023, 11:35 AM
I dont want Swift libraries anyway. Want pure compose libs. Want zero interaction with iOS and Swift if possible :) minimum entry point in swiftui using compose ui view controller. Resources in 1.5.0 is resolved in jetbrains resources. Just complex how need setup.
j

jamshedalamqaderi

11/18/2023, 11:35 AM
check out a demo project how that's doing then do the same with your own project
j

Joel Denke

11/18/2023, 11:35 AM
For Google play services sure I need deep links and app delegate setup. Hopefully they fix KMP in future.
@jamshedalamqaderi Yeah problem most demo projects outdated or not fit my architecture. Want generate iOS app folder from my existing CMP project :)
Especially the xcproject files and such
j

jamshedalamqaderi

11/18/2023, 11:37 AM
i mean from the links generate a project then check them
they are using latest versions
j

Joel Denke

11/18/2023, 11:37 AM
Already did, they do not provide what I want
j

jamshedalamqaderi

11/18/2023, 11:38 AM
for the feature you need you have to combine multiple things to get one feature
there's no easy as i know for now
j

Joel Denke

11/18/2023, 11:38 AM
I have iOS app already worth mentioned, but need new one to adapt into 1.5.0 changes.
Tried refactoring the setup but its very hard.
Like downgrade/delete cocoapods is insanity.
My end goal is have everything in commonMain and almost nothing in iosApp and androidApp. Refactoring resources, firebase auth, google play services and navigation to be agnostic.
@jamshedalamqaderi https://github.com/chrisbanes/tivi/tree/main/ios-app%2FTivi%2FTivi Looks like this project quite updated. But so complex dont understand where they import shared code in Swift TiviKt. Cant find references.
j

jamshedalamqaderi

11/18/2023, 12:02 PM
in that repo decompose has been used which is a navigation system for kmm. So, he initializing that in swift and doing code in shared
j

Joel Denke

11/18/2023, 12:04 PM
Yes thats pretty much identical to my iosApp.swift file. Just curious how TiviKt is generated from and that name. Is it in iosApp xc config files or shared config somewhere. No he uses Slack Circuit :)
Trying very similar approach as he did with Tivi. Just very hard follow config setups without Clone the entire project 🤣
https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-integrate-in-existing-app.html#connect-the-framework-to-your-ios-project This is the insanity level where I get lost in Xcode integrate with Gradle build steps comply with what I need. Especially custom publish app, google play services and such. Or regular iOS build system comply with shared Gradle module with jetbrains compose resources.
j

jamshedalamqaderi

11/18/2023, 12:11 PM
You have to do a lot of research to migrate into an iosApp for all features
j

Joel Denke

11/18/2023, 12:13 PM
Ah there, thank so much! So basename used from Swift scope linked in static things in iOS. Looks like merging different things with basename to switch qa, debug and production.
j

jamshedalamqaderi

11/18/2023, 12:13 PM
if you import the module then you can get access to any class, files, variables from that module
j

Joel Denke

11/18/2023, 12:14 PM
@jamshedalamqaderi Haha Yes especially Xcode configs in IDE make me want throw my MacBook through the window 😁 Find build phases, deep links etc is uhm fun. Does it matter if take someone else project files or can include bad certificate numbers etc?
j

jamshedalamqaderi

11/18/2023, 12:15 PM
just write the code in swift if you are not able to write it in kotlin iosMain sourcesets which is support objective-c. only write code if you need to use swift packages and pass the object to the shared module with some common object that support in shared module too.
j

Joel Denke

11/18/2023, 12:15 PM
Looks like KMP only supports one shared Gradle module. That i solved earlier by inherit multiple linked modules in a chain 😁
To be able share in Android actually supports it.
j

jamshedalamqaderi

11/18/2023, 12:16 PM
If you only do the necessary things in swift code and all the things in other modules and import them to shared -> iosApp
j

Joel Denke

11/18/2023, 12:17 PM
Yeah mostly using shared to creating ui view controllers from compose multiplatform. And bare minimum for firebase auth and notifications
j

jamshedalamqaderi

11/18/2023, 12:17 PM
this way your codebase will look like more cleaner
j

Joel Denke

11/18/2023, 12:17 PM
Yes thats why will start using circuit Slack for navigation instead of iOS native.
To have everything in commonMain in shared
j

jamshedalamqaderi

11/18/2023, 12:18 PM
what do you mean slack circuit?
j

Joel Denke

11/18/2023, 12:18 PM
Also Swift very slow in iOS as well it seems. Want to avoid multiple layers of bindings to objc 😁
Pure KMP navigation with native iOS and Android decorators 👌
No more androidx compose navigation or decompose
j

jamshedalamqaderi

11/18/2023, 12:20 PM
oh. i'm using precompose as like android navigation
👍 1
j

Joel Denke

11/18/2023, 12:20 PM
Yeah currently doing expect actual with androidx nav in Android and vanilla compose in iOS
Want to use as little expect/actual as possible but using the best libraries not lock me into their architecture.
Like delete androidx lifecycle, androidx viewmodels. And soon having Okio, okhttp being pure KMP. Also compose paging KMP.
Just need kotlinx coroutines iOS library 😁
Dispatchers.Main for iOS
j

jamshedalamqaderi

11/18/2023, 12:23 PM
currently we have a lot of things that get us the production app in compose multiplatform
j

Joel Denke

11/18/2023, 12:23 PM
Coil getting KMP soon. Prefer that over Kamel.
I wouldnt yet use CMP for large scale apps. But for smaller indeed its good. Very smooth if need iOS, Android and desktop. Soon web.
Would be cool doing CMS in CMP 👌
@jamshedalamqaderi Any recommendations for publish app in App Store btw? Is Fastlane only thing?
And to answer my own question. Seems my best bet is first create KMP shared module from Android Studio KMP plugin. And then create new iOS app in Xcode. And then copy paste those into a new Gradle root project and try refactoring it to fit my current CMP project 😁
https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-integrate-in-existing-app.html This guide can be used I think to re-structure existing CMP apps :) Looks like latest 1.5.0 changes applied.
1
5 Views