Ktor HttpClient handling close in multiplatform - kotlin-multiplatform

According to the documentation, we should call close method after we are done with http client instance. What is the right way to handle the close method of ktor http client in multiplatform env. ? In my case, I have a KMM project with android and ios. I am using HttpClient in common source set.
Or maybe the close method should be handled by specific applications instead of the multiplatform lib?

Related

SSL Dependency Conflict iOS

I have seemingly 2 libraries that are interfering with each other in regards to their usage of SSL.
One is the Tuya SDK which is added via CocoaPods, and the other is a locally added library, for which I don't have the source code.
When the locally added library tries to use SSL, I get a 'EXC_BAD_ACCESS' error, so there is clearly a conflict. (When I run the local library in a separate isolated project on its own, the SSL works fine.)
Is there any way in Swift to specify to only use one of the SSL files? (So that both Tuya and the local library will use the same, single SSL file).
For example I think you can do this in Android with Gradle, using the FirstPick() Packaging Options{}?

Getting error while adding SwiftKafka package manager in Swift

Getting error while adding SwiftKafka using package manager in Swift. Got error like undefined symbol. I have to added target in targets array in package manage package file but still getting error.
How to use swiftKafka library in swift?
Assuming you're writing an app not for macOS, then Kafka cannot be used with mobile applications, mostly because of network switching.
If that is your goal, you should look into alternatives like the Confluent REST Proxy, and use HTTP calls to its API instead.

Is the a way to reuse an existing Android ViewModel for iOS with KMM

I'm trying to convert an existing Android project to Kotlin Multiplatform Mobile (KMM).
A bunch of the app logic is contained in the viewmodel and I would really love to share said logic with the iOS side.
Is there a way to do that without Cocoapods integration as my iOS side was not set up with Cocoapods?
Viewmodel in Android is own of framework, if you want to share presentation logic, you could use a presenter with CoroutineScope.

Share objects between aqueduct and flutter

I'm using aqueduct as a server where I defined an user object and extended it to make use of OAuth:
class ManagedUser extends ManagedObject<_User> implements _User, ManagedAuthResourceOwner<_User>
After finishing the work on aqueduct I started working on the flutter app and wanted to use the ManagedUser-object in flutter as well, that's why I thought about putting it into a separate project.
The problem I face now (during deployment) is the following:
ERROR:flutter/shell/common/shell.cc(184)] Dart Error: error: import of dart:mirrors with --enable-mirrors=false
As I read here Dart Error: error: import of dart:mirrors with --enable-mirrors=false it's because flutter doesn't seem to support parts of aqueduct (which I unfortunately need in my shared project to use ManagedObject).
So I'm kinda stuck here. What are my options? I really don't like to map all objects again on the flutter side.
You won't be able to combine Aqueduct and Flutter in the same project - they have different compilation targets, and both take advantage of those targets.
The general approach is to use aqueduct document to create an OpenAPI document from your code, then use an OpenAPI code generator to build your client-side code. This approach is preferable to sharing code between the server and clients. Code can be shared between browser and mobile targets. It is a good idea to avoid having one type that represents the database, server and client definition of an object. A client type and a database table mapping will eventually have differences that will be difficult to manage.

How can I call native ios api from cocos2d html5 with javascript binding project?

Can cocos2d html5 with javacript binding project for ios call ios native api? I am looking for the way to access the ios device camera, photos, etc.
Nope. The whole point of the JS API is to have a common subset of the API that works across all platforms (on the web you can't access the camera or a photo library), with the exception of the most commonly needed features like input.
You can write the camera etc code in Objective-C. You can then expose your methods as JS bindings as needed.
You can wrap the Cocos2d-html5 project in Cordova, then use the Cordova methods to call all the native functionality you mention

Resources