Use Swift vapor inside a macOS app - swift

I am not quite sure if this work - so that why I am asking this question:
I have a macOS app based on Swift that is used as a specialized CRM application.
My client wants to use the app on different machines but the data should be fetched from one Mac.
My consideration was to use one app as "server" and the other apps as clients connecting to this server.
Can I use vapor inside an app for macOS for such a scenario?
Can it be used as a library?
I have seen that vapor comes with its own stack of environment - is it compatible to be used inside a macOS app?
Cheers
Sas

Yes. Vapor runs correctly on macOS. There is nothing to stop you 'embedding' Vapor inside another Mac app.
Possible points of concern:
you will need to use the Swift package manager to install Vapor and its packages.
there are other, existing, light weight HTTP servers such as Swifter that may better fit your needs.
But yes, you can use Vapor if you want.

Related

Swift MacOS - Communicate with MacOS app externally

Is there a best practice for externally communicating with MacOS apps?
I have a Rust app launched from a MacOS app via a C-Bridge and I need to let the MacOS app know when it's in the middle of a batch process.
I tried using env vars but ProcessInfo.processInfo.environment lives in it's own little world it seems. I tried writing to Info.plist during runtime but that didn't work either. I remember reading there was some file somewhere that had data the MacOS app could reference but I forget what that was.
Thanks to Roberto from the RayWenderlich.com Discord chat for referring URLSession here:
https://www.raywenderlich.com/3244963-urlsession-tutorial-getting-started
He also mentioned BSD file-sockets as well here:
https://rderik.com/blog/using-bsd-sockets-in-swift/

How could I combine Swift and SignalR?

So, I and a few other people are working a project where one part of the group is doing an Progressive Web App and the other part is doing an iOS app. Our back-end API is in .NET Core C#. We have decided to use SignalR so we can make the apps real-time.
I have done a small research on SignalR and there is not much available information on how to use it with Swift. Could any of you give any recommendations/suggestions on how should I proceed and how I can combine Swift and SignalR?

Use UIKit with Vapor or Kitura

I have developed an iOS App and would like to create a web API with some parts of my code. This API will send an UIImage generated from a UIView.
The problem I have with Vapor is that I only managed to use AppKit, not UIKit. Certainly because the Xcode project with Vapor is a MacOS project.
Is there a way to use UIKit or iOS Swift code with Vapor or any other solutions like Kitura ???
Thanks for your help :)
Regards,
If you want your Backend API Server (Vapor or Kitura) to run in a hosted environment, it will need to be able to run on Linux - where only Foundation is supported.
You can still transfer UIImages between iOS app and server, but you'll need to convert the UIImage to Data first (using something like UIImage.jpegData())
You can see an example of this in the "FoodTrackerBackend" tutorial for Kitura here:
https://github.com/IBM/FoodTrackerBackend

Firebase SDK (v2.5.0) in OSX framework

I'm trying to link to the Firebase SDK (v2.5.0) within my OS X framework, but it keeps telling me I am trying to link to a framework built for iOS.
It seems to state pretty clearly on the Firebase docs that the iOS framework can be used to build OS X clients as well, so does anyone know what I am doing wrong here?
ld: in /[...]/Firebase.framework/Firebase(Firebase.o), building for OSX, but linking in object file built for iOS, for architecture x86_64
As of 2.4.0 (changelog), Firebase no longer ships a single binary for iOS and OSX, but instead has multiple frameworks (Firebase.framework for iOS, FirebaseOSX.framework for OSX). Similarly, the iOS Cocoapod is named Firebase, while the OSX Cocoapod is named FirebaseOSX. This is due to several changes in our build process, such as adding bitcode support (which only makes sense on iOS).
We still build and release iOS and OSX through these channels, and continue to support OSX, though it's not heavily advertised (as you noticed). As mentioned, if you don't use Cocoapods, using https://cdn.firebase.com/ObjC/FirebasePlatform.framework-major.minor.patch.zip will get you the framework, then follow the Alternative Setup instructions for including it in your project.
You need to add some dependencies in your project's Build Phases:
libicucore.dylib
libc++.dylib
CFNetwork.framework
Security.framework
SystemConfiguration.framework
See the Apple docs on how to add these if you haven't done this before.
Ok, this is a bit weird.. But after digging around in the pod specs I noticed that the FirebaseOSX podspec links to a different url than the iOS pod (FirebaseOSX.framework and an older version).
So I decided to copy the framework url from the Firebase site, and change the name and try that, and it downloaded a OSX framework for me. This is really weird, because I can't for the life of me understand that I should do like that based on what I can read on the Firebase site, so I can't really consider this the official way as it doesn't really make any sense. But it seems to work for now..
So for v2.5.0 the url is:
https://cdn.firebase.com/ObjC/FirebaseOSX.framework-2.5.0.zip

platform independent sqlite data access layer for ipad / iphone / android / samsung bada

we have an app which is available for ipad, iphone, android as well as samsung bada. since all of these platforms support sqlite, this app makes extensive use of sqlite for saving and reading data.
we now face quite a lot of issues whenever we need to update our app, that is punch in the same data access code across 4 different apps. we might also be looking to publish this app for windows mobile at a future date
i was wondering if there is a way to atleast have a completely independent library to manage our data access part so that we can just code and update this library once and simply use it across all 4 platforms
it would be awesome to achieve that and it would save us plenty of hours of coding and debugging and testing
No, because what you are asking for is essentially a SQL client layer sitting on top of SQLite similar to Oracle's SQL Client for Linux, Windows and so on that sits on top of the Oracle DB server that a developer could code to. This SQL client layer would have to define a standard interface (think JDBC or ODBC) and be implemented in Java (Android), C#, VB, and F# (Windows Mobile 7), and Objective-C (iOS).
Having said that, do I expect to see such a chunk of software developing over time, considering that SQLite does seem to be the defacto standard on handsets? Yes, I would expect to see something pop up on Git somewhere in the future that does something like that.