Creating a Xamarin Binding project for PebbleKit iOS - ios

For the past while I've been trying to create a binding project in Xamarin for PebbleKit iOS (the SDK for the Pebble smart watches). My hope is that in doing this I can create a Xamarin C# app that communicates with a Pebble smart watch, just like how you would in Objective - C.
Here is a link to the github page containing the code: https://github.com/dankunc/PebbleKit-Xamarin/tree/master
Also, here is a link to a simple harness project that just contains a button you can use to test out the binding project: https://github.com/dankunc/PebbleKit-Xamarin-Harness
Note: If any of you are kind enough to download the code and try it out, you'll probably need to update the reference path in the harness to the .dll in the binding project (PebbleKitAll/bin/release/PebbleKitAll.dll)
The project compiles, however when I go to use it in an actual Xamarin app, this code returns null to watch:
var watch = PBCentral.DefaultCentral();
In objective - c, the equivalent method would never return null, and I've been struggling with this for quite some time.
The PebbleKit binding project relies on two .frameworks from Pebble (PebbleKit and PebbleVendor) and a handful of other frameworks that get included in the harness project. I generated the ApiDefinition and StructsAndEnums files from using Objective Sharpie which I then cleaned up afterwards.
If anyone is able to help me with this, or if I need to provide more information or anything else, please let me know, and anything is appreciated. I've been struggling with this for quite a while and am at wits end. Thank you.

Related

What is the difference between an "app" project and a "framework" project in Xcode?

I am working on a project with SwiftUI and it originally started with creating a new project as an "App" (Xcode, clicked on file, new, project, click on "App") but was then later asked to put it into a pod as a framework. I did it successfully (Xcode, clicked on file, new project, click on "Framework"), however I am unsure what the differences are and I'm unsure why I would want to do that. To me they look very similar, except that I'm unable to launch my project as a framework in the simulator. Luckily SwiftUI offers the canvas preview window however it is a bit finicky when it comes to certain button interactions, which is why I am wanting to use the simulator.
Two places of confusion:
What is the difference between an app and a framework project?
Why is it more advantageous to have my project as a framework?
An App is a standalone application that can be launched and run. For example, all of the apps that you have on your phone are just that -- apps. You tap on them and they launch and run, presenting a user interface, accepting input, etc.
A framework is something else entirely. It's a collection of code that is bundled together into a package that is used by another framework or by an app. Some frameworks are provided by the system -- for example, SwiftUI is a framework that it sounds like you're using in your app. Other frameworks are provided by 3rd parties. For example, you can find many frameworks via CocoaPods or the Swift Package Manager -- Alamofire is a common example. Also, you can make your own frameworks and use them in your own code as a form of organization and separation of responsibilities.
Why is it more advantageous to have my project as a framework?
It is not -- they are two almost completely different concepts (besides both ultimately being collections of code and resources). If you intend to build an app that is launch-able on someone's device, your only choice is to make an app. If you intend to make a collection of reusable code for use in your or someone else's app, than you would make a framework.
Excellent answer (and upvoted) by #jnpdx. Let me give you a physical example:
(1) Create a project in Xcode that is a framework. Call it "MyAppKit". Inside it create, well, basically anything - a View, UIView, or more likely a function that will be shared by several views. (Let's go with that.)
public func setLoginName(_ login:String) -> String {
return ""Hello, " + login + "!";
}
Pretty simple. Call it, pass in something, and it returns a string saying hello. Please note the public piece. It matters. (And there's much more there. This is a simple example.)
(2) Now we get to your app or apps. Let's say you have two apps that need to use this (again, very simple) code. One is SwiftUI, one is UIKit. (It doesn't matter except for syntax.) Sine my forte is UIKit I'll use that. (And it can be several dozen apps too.)
import MyAppKit
let myLoginMessage = setLoginName("World").
Pretty much, it's "Hello, World!'
Again, this is really a nonsensical example. But it should get you started on what the difference in Xcode is between a Framework project and an App project is.

ANPR for XamarinFroms

We are searching best ANPR (Automatic Number Plate Reader/Recognition) for Xamarin.Forms. I have already gone through AnyLine and OpenAlpr.
AnyLine seems to be high cost, based on image capture counts.
Regarding OpenAlpr we have a workable solution for Xcode (IOS) and also Xamarin.Android.
The real problem is we couldn't bind the existing xcode project into xamarin.IOS using the sharpie tool (we tried sharpie for some other project, that works fine). Then we realized, that we can't create static library in xcode using an existing framework(openalpr.framework) files.
My question are,
Can we create static library using .framework file? please explain.
Else, Is there any other ANPR tools already available for Xamarin.Forms of Xamarin.IOS?
MicroFocus IDOL has an excellent ANPR Solution which can be accessed via REST APIs. The product is called Media Server.
https://www.microfocus.com/media/flyer/fast_and_comprehensive_vehicle_identification_flyer.pdf

How do I build a Cocoapod framework for swift, while keeping implementation details hidden?

I am trying to build an iOS swift framework to display encrypted photos. Photos are sent by my server (something like a hashed binary file) after calling a specific API with specific details. I will then decrypt the photo, and display it to the user.
Correct and point me in the right direction if I am wrong, but swift only allows frameworks - meaning no static library. And this will expose my implementation details (such as the method to decrypt my photo).
What I would like to achieve is to create a cocoapod distributable framework for paid developers to implement (once they subscribe to me). It is supposed to expose simple public APIs, and hide implementation details.
I have tried various ways to achieve that but to no avail. I would really like to keep the implementation to swift codes only, with minimal Obj-C codes.
Build a swift framework, and build an objective-c static library as a wrapper
But I cannot seem to get it to work. Any idea if this is possible?
Build a swift framework in a swift framework
Stupid idea, i'm able to see the framework's implementation details within the other framework...
Build a swift framework, and build an objective-c framework as a wrapper
I cannot seem to get this to work either...
I have been working on this project for about 2 weeks now, and have been all over Googling for it. Just in case anybody would like to try, you may try to do the following and check if it works.
Cocoapods Friendly Framework
Implementation Details Hidden
Uses Alamofire (or any public framework that connects to internet)
Any help would be appreciated, thanks!

iOS Widevine with Xamarin

I am needing to use the widevine api in an ios app written in xamarin. From what I understand I need to make a wrapper for the library and such, but I have no idea where to start. Can anyone either explain in more detail what to do, or point me somewhere that explains it well?
Thanks, I am quite new to Xamarin, and rusty on C#
You definitely want to follow Jason's comment. In short, you need the .a (fat library) and the header files and then create a Xamarin.iOS binding project that exposes the native interface to C#. Access to the source code is not necessary.

Creating an iOS library or framework using libgdx (roboVM)

Is it possible to create an iOS library or framework using libgdx (RoboVM) that can be imported into Xcode?
Background:
One of my colleagues has created a 3D visualisation app as a libgdx project for android and windows desktop. It can be compiled to run on iOS using RoboVM. However, I would like to wrap extra native user interface elements around it using Xcode. I know its possible to build the user interface programmatically via RoboVM but I would be keen to investigate if its possible to bring the existing work into Xcode. I don't need to edit the 3D visualisation component but add extra GUI elements around the 3D Vis window. I thought compiling the libgdx (RoboVM) code to a framework or library might be a solution that could be imported?!
Yes you can do it.
All you need to create a method, say initRoboVM(), This will be called by your code when you want to initialize libgdx. You'll need to pass the app path in, which you can hardcode when you're testing.
initRoboVM() will need some modifications, namely it should not call your Java app's main method, well, at least, that's what well behaving libraries should not do IMO. It should also not call rvmShutdown.
You can get further information from here
Thanks :)
I asked the RoboVM team directly. Their answer: It's not a native function, but it certainly can be done.
The complete message...
Hi,
Sorry for the late reply. This use case is not something we're going
to do now. It is possible though if you're prepared to do some
patching of RoboVM. Search the RoboVM Google Group and you should find
others who have managed to get this working.
We get this request every know and then so we will add support for
this eventually.
Regards, Niklas

Resources