-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add iOS target using Compose Multiplatform #312
Comments
If you would like to upvote the priority of this issue, please comment below or react with 👍 so we can see what is popular when we triage.@dogeweb Thank you for opening this issue. 🙏
This is an automated message, feel free to ignore. |
This is interesting! Adding a |
An existing challenge with Compose multiplatform apps pertains to the availability of appropriate libraries for incorporating the Map feature. The prospect of Google extending its support in this regard holds immense potential, as it could significantly bolster the advancement of Compose Multiplatform apps. |
I have had success with using compose for iOS with UIKitView to render google maps. Maps are currently rendering on iOS and Android. All standard map interactivity is working. Markers and paths are displaying properly. Here's a link to my repo. https://github.com/realityexpander/ContactsComposeMultiplatform The part I'm currently working on is the "on_____Click" call backs. Right now I am not able to write custom map event callback handlers for "on____Click" events. This is only a problem in the iOS stide. I'm an Android dev, so I'm not sure whats necessary to make the work using Kotlin on the iOS side... all the sample code does not refer to this use case. NOTE: Be sure to manually give location permission on the Android, I havent implemented that part yet. you will need to get your own google maps api key. This is still a work in progress, and its a good head start! |
Hi @realityexpander! Thanks for the message, it is great to see that Android Maps for Compose can be used in KMP! We merged recently #320, which introduced default values for the listeners. I suspect that this prevent listeners from working out of the box: default parameters in iOS are not supported, since the interoperability happens from Kotlin - Objective-C and Swift, so ultimately Objective-C needs to support them. I wrote an article about it here. Touchlab released a couple of days SKIE, which promises to fix this issue. I haven't check it yet, but I would like to take a look. Eventually it seems that Android-Maps-Compose could work relatively out of the box for iOS. |
So am I to understand that ive hit a dead end with looking to get "onMapClick" type of events from the Google MapView on iOS? That I should probably wait on the Google Maps iOS "onMapClick" types of integrations? That its likely not possible now without more low level work from the Google Maps team? Should I file a bug report or feature request, or are they already aware of this issue and we are just waiting for them to catch up to KMP? |
i found the way to handle click on marker:
|
My versions....
Any ideas? Are you using the same versions? |
and androidMain:
|
Yes, i have it working on the Android side with no problems... this is an iOS issue... Can you show the iosMain gradle versions? Do you have the functionality on the iOS side? Are you receiving callbacks on the iOS side for the Google Maps? Yes, it compiles... but does it execute? |
Where would that get posted? Im sure they know about it, the way im handling it on iOS side is a bit of hack, but it works, so we know it will improve from here. |
Yes it works well on the iOS side. Above I have attached a screenshot where you can clearly see the log with the print.
Btw use "val googleMapView = GMSMapView()" not " val googleMapView = remember { GMSMapView() }" that helped me. |
GoogleMaps.zip |
OK, im confused here…
Is the Google Maps “tapOnMarker” functionality working for you on the iOS side?
Yes, it all works on Android, that’s not the problem.
Are you able to use the “tapOnMarker” callback on the iOS side, or just giving the compile warning and doesn’t actually received tap events?
Thanks for the responses!
Best,
Chris
… On Oct 19, 2023, at 2:19 AM, MascotWorld ***@***.***> wrote:
GoogleMaps.zip <https://github.com/googlemaps/android-maps-compose/files/13039249/GoogleMaps.zip>
it's from ur project, all working properly
—
Reply to this email directly, view it on GitHub <#312 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABHLEYXP5PS5ETQKUQE6JWDYADH7BAVCNFSM6AAAAAAXF6YCHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZQGIYDOOJTGI>.
You are receiving this because you were mentioned.
|
The callback works great! you can check it yourself, I attached the file GoogleMaps.kt (from iosMain), you can replace it in your project and run it. |
i have same error, but project is compiles. Here is whole project(with build files) with working click: https://drive.google.com/file/d/10vpPs69yPxUMNiTv9UCXuHbkDoVnTdru/view?usp=share_link You can check it out. in root is screen record where i show work |
WOW! Thank you for supplying this... I loaded your supplied project in both AS Giraffe and Hedgehog (Iguana is too new yet), and have the same problems... Im now wondering what version of AS you are running? Here's my version info:
|
this is my
|
It looks like we are using different versions of the jetbrains KMM plugin. You have an earlier version, and mine is the latest... looks like they broke it in the latest version... mine: Im going to explore if I can downgrade, or I'm locked in to the latest version. |
Maybe this is the point) Try downgrading and report back how it turned out |
Just tried to use it with the 0.6.1 version of KMM plugin inside Flamingo (newer AS are incompatible and will not load the plugin) - Still has the same issue. So, Im going to chalk this up as an unsolved mystery and await a better solution from google soon. At least the Android side works great, and compose is not an issue... It's a c-interop library issue. Since they addressed it on the Android side for Google Maps in Compse, I can only assume Google or Jetbrains are working on this for compose for KMP. |
can you show the error? my android studio itself updated the plugin (ahem) and I received an error related to Could not find "co.touchlab:stately-common" and I solved it) |
It's the same error as before |
Its the exact same error as I have been showing in my previous replies.
Going back to previous versions of AS and KMM plug-in are not solutions for me at this time
Chris
… On Oct 23, 2023, at 4:02 AM, MascotWorld ***@***.***> wrote:
Just tried to use it with the 0.6.1 version of KMM plugin inside Flamingo (newer AS are incompatible and will not load the plugin) - Still has the same issue.
So, Im going to chalk this up as an unsolved mystery and await a better solution from google soon. At least the Android side works great, and compose is not an issue... It's a c-interop library issue.
Since they addressed it on the Android side for Google Maps in Compse, I can only assume Google or Jetbrains are working on this for compose for KMP.
can you show the error? my android studio itself updated the plugin (ahem) and I received an error related to Could not find "co.touchlab:stately-common" and I solved it)
—
Reply to this email directly, view it on GitHub <#312 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABHLEYWNSGDD4QWZVZIA7Q3YAYXA7AVCNFSM6AAAAAAXF6YCHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUG4ZTSMBUGE>.
You are receiving this because you were mentioned.
|
@realityexpander there is a regression introduced in android-maps-compose 1.4.21 that causes recomposed GoogleMap listeners to not be used. Wonder if this might contribute to your obstacles. #466 |
Its a compile time issue, the compiler gives a warning and the listeners are not setup properly. This is an internal google library issue and hopefully there will be a fix soon. |
The
definitely works. You just have to run the iOS app via Xcode and not via AS. with AS, I have the same issue like you @realityexpander, I can't compile & have the same error ( Maybe you can try running the iOS app via xcode instead. |
I'll give it a try, i did not try compiling and running from xcode. UPDATE: The app does indeed compile from XCode, but I was not able to get any responses from UI taps on iOS using either print statements or debug breakpoints. Feel free to share your project and version information for all the libraries and IDE's... |
Sharing support for Compose maps for kotlin multiplatform! Yes please! |
I have made substantial progress on this by taking a different approach.
You can check my work at:
https://github.com/realityexpander/FredsRoadtripStoryteller
… On Dec 19, 2023, at 8:47 AM, ColtonIdle ***@***.***> wrote:
Sharing support for Compose maps for kotlin multiplatform! Yes please!
—
Reply to this email directly, view it on GitHub <#312 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABHLEYVFKDPL7K62YALHWTLYKGSJNAVCNFSM6AAAAAAXF6YCHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRSHA4TMOBXGA>.
You are receiving this because you were mentioned.
|
Here's a playlist on yt about how I approached the project: |
@wangela Any news for this topic? |
This would definitely come in handy! Any new information on this topic? |
Any update on this? |
In the meantime you could implement a platform specific logic. Watch my video: https://www.youtube.com/watch?v=Km2KxsWS-NU |
Describe the solution you'd like
Add platform-specific code for iOS, using JetBrains Compose Multiplatform.
JB Compose iOS support is now in Alpha compose-multiplatform/releases/tag/v1.4.0 and enables the use of UiKit views in Compose.
Kotlin Multiplatform Mobile recently moved to Beta and
cocoapods
integration works: kotlinlang.org/docs/native-cocoapods.htmlSince
android-maps-compose
library is a wrapper for an Android view, it may result easy to adapt the existing structure to wrap also iOS objective-c Maps sdk.A quick implementation labeled as
alpha
could come handy for developers to start playing with it, while waiting JB Compose iOS support to exit Alpha state.The text was updated successfully, but these errors were encountered: