Merged
Conversation
…ly imported into Swift)
dpad85
approved these changes
Mar 7, 2024
Member
|
@robbiehanson Since this is a significant change it will need quite a lot of testing. So we can merge this PR to master now, but if we need to patch the mainnet iOS app for some reason, then we'll have to fork from an earlier commit. |
robbiehanson
added a commit
that referenced
this pull request
Apr 11, 2024
dpad85
pushed a commit
that referenced
this pull request
Apr 12, 2024
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The interface between Kotlin & Swift has always been ... let's just say it leaves something to be desired. The root cause of the problem is that Kotlin libraries are exposed via an Objective-C layer, which is then converted to Swift.
This is a bit like converting Spanish to Japanese, and then from Japanese to Italian. It would have been much better to do the conversion directly, and taking the longer route means things are lost in translation.
However, Touchlab has released a tool called SKIE (Swift Kotlin Interface Enhancer), which is a drastic improvement.
For example:
Previously, if Kotlin exposed something like
ratesFlow: StateFlow<List<ExchangeRate>>, then in Swift we had to write a wrapper function:Plus there's custom code for
getSetAssociatedObject, and a custom classKotlinCurrentValueSubject.With SKIE, you can just access the value directly:
So we can drop a bunch of boilerplate/workaround code that we had. Plus we get to switch from the old Publisher syntax to the modern async/await syntax.
It's important to note how SKIE actually works:
In other words, we don't have to change the way we write the Kotlin code. We just get a much better interface on the Swift side. And the improvement is so drastic, I do wonder if the Kotlin team will officially adopt this approach.