https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
r

Raed Ghazal

09/21/2023, 12:47 PM
Hey, is there a way to view the shared directory from xcode? tried installing
xcode-kotlin
but it lead to xcode crash everytime i try to open it
d

Daniel Seither

09/21/2023, 12:56 PM
I find it useful to add the Kotlin source folders to the Xcode project as folder references (Add Files to …, then uncheck Copy items if needed and select Create folder references). This adds the folders to Xcode’s project navigator and lets you open them via Cmd+Shift+O just as any other source file in the project.
v

Vlad

09/21/2023, 1:44 PM
I wonder how iOS developers actually develop on KMP. Can you use only XCode? Can you use only AS? Or you always need to use both?
d

Daniel Seither

09/21/2023, 1:54 PM
In my experience: definitely both.
2
r

Raed Ghazal

09/21/2023, 1:55 PM
I wonder how iOS developers actually develop on KMP.
I think its mostly the Android team would be the one to push it (kinda force it) on iOS guys, so I don’t think any iOS person will be interested in creating a KMM project 😆
thank you @Daniel Seither let me try that out
am I doing it correctly? just select the shared folder?
👍 1
v

Vlad

09/21/2023, 1:58 PM
Yea, iOS devs are not interested in KMP. We are currently struggling with finding a developer for iOS side.
r

Raed Ghazal

09/21/2023, 2:00 PM
yeah, its like asking you to write in swift and kotlin to implement a feature in Android, I wouldn’t like it, but once it has good resources and its more popular I think it will be used more to save time as most of the code would be shared, so it will be rather a company request at that point
btw @Daniel Seither is there I way I can open the kotlin source class when I click on it from xcode swift? e.g. in xcode, if I click
cmd
and click on
Greeting()
it forwards me to the kotlin reference not the swift translation
d

Daniel Seither

09/21/2023, 2:16 PM
is there I way I can open the kotlin source class when I click on it from xcode swift?
No, I don’t think so. The integration is not great.
r

Raed Ghazal

09/21/2023, 2:16 PM
yeah.. alright thank you then thank you color
hope it gets better support by time
ok as we’re here, I’m heavily using java.time.LocalDateTime in my project, and well, this is java, is there a kotlin replacement that is not much different in implementation?
is this a good replacement? https://github.com/Kotlin/kotlinx-datetime
v

Vlad

09/21/2023, 2:36 PM
I mean, it is in kotlin repository and already has 1900 stars
Does it really matter at this point if it is actually good?
r

Raed Ghazal

09/21/2023, 2:37 PM
haha, yeah my concern was that I need to find something that will have minimal changes, rather than just reliable
cuz my whole app relies on time objects
but I’ll try this one first and see
m

mkrussel

09/21/2023, 5:30 PM
The main thing missing from the kotlinx-datetime library is formatting and parsing. But you can create some expect/actual to handle that if needed.
r

Raed Ghazal

09/21/2023, 5:31 PM
yeah 3 hours into it, I hate it, its actually missing a lot of things, or has wordarounds for easy things in the java one formatting, parsing, calculating TimeUnit between 2 dateTimes…
I’m figuring each one on its own
now also missing
plus
function on LocalDateTime and LocalTime, there is
plus
only in LocalDate for some reason
still haven’t figured that out
Copy code
datetime.plusMinutes(start)
now looks like this
Copy code
datetime.toInstant(TimeZone.currentSystemDefault()).plus(start, DateTimeUnit.MINUTE).toLocalDateTime(TimeZone.currentSystemDefault())
I hope I’m doing something wrong and things not as complicated as they seem to be now 😅
v

Vlad

09/22/2023, 8:54 AM
Formatting and parsing? Like if I want to get a string 50 sec ago / 5 min ago / 2 days ago/etc I will have issue? Which is often used for messages, even like here, in the slack
15 hours ago
r

Raed Ghazal

09/22/2023, 9:02 AM
yeah its not as intuitive and easy as java.time, also for formatting you have to use java DateTimeFormatter, so I ended up creating an
expect
class and 2 actual classes for formatting, on in Android and on iOS (didn’t implement the iOS one yet)
will probably write an article about it, cuz my app relies a lot on time so I used almost every functionality someone would think of 😅
also a downside: there is almost no resources
v

Vlad

09/22/2023, 9:03 AM
As for pretty much anything
r

Raed Ghazal

09/22/2023, 9:03 AM
yeah, KMM is lacking a lot of resources
I also struggled while migrating from Room to SQLDelight, so wrote an article about it for others. trying to add some resources to the internet to fill in the gab a bit here it is if someone is interested
v

Vlad

09/22/2023, 9:05 AM
Dunno, it wasn't issue for me to swap room for SQLDelight for a new app
r

Raed Ghazal

09/22/2023, 9:07 AM
yeah in a new app its easy, issues come when its an existing app that you’re trying to make a KMM app 😅
v

Vlad

09/22/2023, 9:08 AM
Copy code
Kotlin multiplatform (KMP), previously known as (KMM)
r

Raed Ghazal

09/22/2023, 9:12 AM
yup, kotlin deprecated the term “KMM” which used to stand for “Kotlin multiplatfrom mobile” https://x.com/kotlin/status/1686018987304292352?s=20
4 Views