Is there a way to to use the AWS sdk in `shared` f...
# multiplatform
j
Is there a way to to use the AWS sdk in
shared
for KMP?
k
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
I'm using S3 to host images
d
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
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
@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
if it's in C or Objective-C, you can write a Kotlin wrapper that interops with it
d
Justin Xu; look into CocoaPods integration, it may be the most convenient route.
j
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
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
213 Views