Is there a WebSocket client library for iOS when using Kotlin? - websocket

I am looking for a WebSocket library that I can use in a Kotlin Multiplatform project for my iOS implementation. This project is currently in IntelliJ and I am using Gradle to manage dependencies.
I have not been able to find a library that supports iOS and that I can specifically pull into my project via Gradle.
The likes of Starscream, Socket.io, SocketRocket etc seem to only have a means of importing dependencies within Xcode/CocaoPods and nothing via Gradle for my IntelliJ project.
To give some more context I have the following for my project
Kotlin Common code for all my common functionality for the project
Platform specific code for my WebSocket implementations for Java, JavaScript and iOS/Swift
The reason for the platform specific implementations is because I have not found a common library that supports WebSockets for all platforms.
Ktor comes close, but from what I see in their documentation their WebSocket client does not support iOS while their Http client supports all platforms.
If anyone has any recommendations that would be really helpful.

The guys from ktor said that they are working on bringing Websockets to iOS but it's still a few months from release.
I haven't tried it yet but you can import cocoapods to an multiplatform project so maybe you can use it that way, but note that it will only compile in xcode.
Also you should join kotlinlang on slack, the guys from jetbrains are really active there and will usually have an answer in a day.

Related

Importing KMM library in multiple iOS modules via Cocoapods results in "... implemented in both ..."

I have been maintaining a shared library built with Kotlin Multiplatform for our Android and iOS native apps for quite some time now. Was working great until I decided to split the iOS app into multiple modules (frameworks). For starters I have one iOS app project and two dynamic frameworks, which are used by the app project. All 3 projects are using Cocoapods for 3rd party dependency management. Own modules are imported via framework embedding. No Cocoapods for the own modules needed, because we don't plan to make them available to other projects.
So the issue I am facing now is that whenever I import the KMM framework into more than one of the modules via Cocoapods, the build succeeds, but I receive errors at runtime like
Class MyClassInKMMProject is implemented in both
/Users/{user}/Library/Developer/Xcode/DerivedData/MyApp-hcbcxlfmsfiiqaccahedgcclxmiq/Build/Products/Debug-iphonesimulator/Common.framework/Common
(0x1189318d0) and
/Users/{user}/Library/Developer/Xcode/DerivedData/MyApp-hcbcxlfmsfiiqaccahedgcclxmiq/Build/Products/Debug-iphonesimulator/Core.framework/Core
(0x112a77ea8). One of the two will be used. Which one is undefined.
Since I need the shared KMM library basically in every module, I am stuck right now with this issue.
In some community I remember that someone mentioned static libraries can be imported only once when using multiple modules. But as far as I understand KMM generated frameworks and not static libraries.
I also tried using XCFrameworks instead of Frameworks, but it didn't change anything.
Anyone here knows how I can fix this?
Tried to find a solution for several days, but just found it after writing this question.
Adding isStatic=false to Gradle was the solution, which I got from this post: https://stackoverflow.com/a/65420364/390542

How to use Couchbase.Lite-PCL in a Xamarin Forms project?

I see there's a Couchbase.Lite-PCL in nuget which has been published recently. Is this capable of running in the PCL? Anyone knows how to make it work? I couldn't find any documentation on this.
It is not an official NuGet package, so your milage may vary.
It does have the dll's in a portable folder, and the dll's are added fine to a PCL and the project seems to build.
Try it it, it might work fine, but don't expect any direct support from the couchbase people.
Alternatively you could implement an Interface in your PCL, which you implement per platform with the methods you need from the official couchbase nuget. Then inject that platform specific implementation at runtime through the IoC container Xamarin.Forms provide.

How to create custom library with gradle `compile` support in AndroidStudio?

I'd like to create my own gradle library, that can be compiled into other projects using gradle compile statement.
Example from Picasso's README:
Download the latest JAR or grab via Gradle:
compile 'com.squareup.picasso:picasso:2.5.2'
I'm developing few applications that share common source: fragments, views, some logic... Sometimes I extend these sources while I'm developing app A, sometimes while I'm developing app B,... And I feel that copy-paste of packages/classes in Android Library Module is not an proper solution.
So I would like to setup my own library, that:
it could be easily deployed to as gradle library that could be used by compile.
I can easily develop/extend it together with currently developed application
Disclaimer: I had been googling it a lot, but without luck.
If you want to reuse a library across completely separate projects then you'll want to publish your library to repository. Assuming this is open source and you don't mind sharing, you could use JCenter, which is already added as a repository to Android projects by default.
https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/

How do I implement dynamic reloading in Spring (Netbeans)?

I'm used to writing Grails applications where my view or controller changes are automatically redeployed on save. I'm now stringing together a Spring Web-
MVC application and I'd like the same feature.
I'm using Netbeans as an IDE, Gradle as a build tool and the spring-boot plugin at the moment. I remember some talk of people using Jetty as it's so quick to restart that dynamic class reloading / deployment is no longer necessary. I've heard others mention JRebel which I used to use a few years back. I'm sure there is a more modern, spring-supported / spring-standard way of doing it.
I'd also like to know if you recommend deploying as a WAR or as a standalone executable JAR with a lightweight built-in web server.
Recommendations appreciated.
A yet unsolved challenge
It turns out that the Netbeans Gradle plugin does not support "compile on save" out-of-the box - and this means that a Java Agent won't be able to pick up the changes. The author kelemen suggested one or two approaches around this. It's a non-negotiable for me, so I decided to switch IDE's to Eclipse (terrible Gradle support), then IntelliJ Idea - which is looking very promising.
Netbeans Gradle Author Comment: https://github.com/kelemen/netbeans-gradle-project/issues/183
Alternatively, there is Jrebel, which is claimed to be able to support this Netbeans / Gradle combination. I wasn't able to get it working easily using a trial of JRebel. The JRebel support guys are there to help, so if you're willing to pay the price, it's likely that their support team will solve your problems.
JRebel: http://zeroturnaround.com/software/jrebel/
If anything changes, please comment below...
Spring class reloading is supported by HotswapAgent as well. It is free alternative to JRebel.
Spring has their own agent as well: https://github.com/spring-projects/spring-loaded. While developing why not just use embedded Tomcat/Jetty provided by Spring Boot.

Build tool for iOS and Mac projects

I don't like to depend on the IDE (Xcode) to build my projects, I want an IDE-Free build tool for iOS and Mac projects.
In Java we could use Ant, Maven, Gradle, Raven...
We open-sourced our XCode Maven plug-in some weeks ago. At SAP we use it to build all our iOS apps and libraries centrally with Maven and manage dependencies in a product standard compliant way.
Some overview documentation and binaries on Maven central are still missing, but the sources and technical documentation are already available on Github. If you have questions please write to our mailing list. We will try to help you.
xcode-maven-plugin1
xcode-maven-plugin2
Kind regards, Alex
We use successfully ant for building iOS projects. Basically we need it for continues integration (we use Jenkins). Most developers prefer using XCode IDE, but some of them sometimes (I would say rarely) use ant for quickly building projects from console after quick small change.
Basically you need to call xcodebuild using ant task. But if you need more complex examples google for jenkins (or hudson) + xcode (or iOS, iPhone).

Resources