https://kotlinlang.org logo
Title
j

Justin Xu

02/25/2023, 1:11 AM
Is there a way to to use the AWS sdk in
shared
for KMP?
k

Kirill Zhukov

02/25/2023, 1:16 AM
Amazon has KMP SDK lib but it only supports JVM and Android at the moment: https://github.com/awslabs/aws-sdk-kotlin
What services are you looking for to use?
j

Justin Xu

02/25/2023, 1:16 AM
I'm using S3 to host images
d

darkmoon_uk

02/25/2023, 1:56 AM
In general the answer to can I use <Service> in KMP is answered by 'How can I use it on each of my target platforms without KMP?'. That answer might be different for each platform: For example if I wanted to interact with Atlassian Jira, I might have a convenient SDK available on Java, but have only the REST API to use on iOS. Regardless, if the answer is 'yes' in some form, for each platform, then the answer is 'yes' for KMP. The only caveat to this that comes to mind is where pure-Swift iOS libraries are concerned, and even then you can create your own ObjC wrapper for them. Anyway, once you've established the normal, non-KMP integration method for the service, for each platform; then look to Kotlin Multiplatform's interop documentation. Honestly given the early maturity of the KMP ecosystem at present, there aren't a whole host of libraries to integrate every service on every platform. But that's ok! KMP really makes it a quite easy and joyful exercise to build integrations ❤️ 🙂
e

ephemient

02/25/2023, 4:38 AM
in theory, tools like https://developers.google.com/j2objc and https://github.com/google/j2cl may be able to rebuild Java dependencies for native and JS. I'm not aware of anybody that has done the work needed to integrate that, though
for AWS specifically though, since they already have native SDKs, the better solution (until they provide multiplatform support in a single SDK themselves) would be to wrap each platform's SDK in common interfaces that you can expect/actual
j

Justin Xu

02/26/2023, 4:57 AM
@ephemient The IOS
actual
implementation would still have to be in kotlin no? I can't find a way to make AWS IOS sdk to work in kotlin. Maybe using AWS S3 through network calls is another option in multiplatform?
e

ephemient

02/26/2023, 5:10 AM
if it's in C or Objective-C, you can write a Kotlin wrapper that interops with it
d

darkmoon_uk

02/26/2023, 5:15 AM
Justin Xu; look into CocoaPods integration, it may be the most convenient route.
j

Justin Xu

02/26/2023, 5:18 AM
I'm new to multiplatform, from my understanding using the IOS SDK through Cocoapods still runs in Swift/Objective-C? I only plan to use S3 to serve images so maybe it's just more convenient for me to just use AWS API Gateway, which will still work in multiplatform
e

ephemient

02/26/2023, 8:18 AM
parts of the S3 API still requires some non-trivial code - notably, you'll still need some multiplatform cryptography to perform its request signing, which isn't built into stdlib