Creating and exporting a Metal library - ios

I see that Apple documentation usually focuses on creating Metal libraries that can then be loaded using the Metal API from Swift or Objective-C, but I am trying to create a library that can provide utility Metal functions to projects that would import it (so you would #include <MyLibrary/Header.h>. Unfortunately I can't find anywhere how to do this:
I see no clear way of doing this as part of a Swift Package (which is what I would have preferred), since I would need a way to tell Xcode that the package contains a Metal Library it should link with the current project library
I also tried the "Metal Library" template in Xcode, but I don't understand how it should be used.
What is the correct way of doing this?

Related

Where can I find new Cocoa Touch Framework project in XCode?

I'm following a tutorial to learn to make a cocoapod. Unfortunately the tutorial instructs to create a "Cocoa Touch Framework" when that no longer exists in current XCode.
What's the current equivalent, that I can use for the purposes of this tutorial / to make a cocoapod?
The answer isn't too complicated: it's the "Framework" option.
A Static Library is pure object code (a.k.a. compiled code), and it cannot contain images, storyboards, etc. Pure object code also means you can't read the code files which makes it pretty much un-debuggable.
A Metal Library lets you develop using the Metal library, basically for 3D graphics and GPU stuff.
Framework is a cocoapod framework. Tried and tested and loved by all Apple Developers.

Swift package manager: How best to indicate platform dependent code?

The Swift Package Manager (SPM) allows support for different platforms (e.g., iOS, macOS). I'm adapting a Swift library to use SPM, and the need is for some of the code for iOS and macOS to be shared, but to have some differences as well.
I've seen a similar example of this with the Facebook libraries:
https://github.com/facebook/facebook-ios-sdk/blob/master/Package.swift
In that case, they use multiple targets, each with its own (independent) code. This is not an example of platform dependency, rather of target dependency.
I see two paths forward:
1) Have separate library targets for iOS and macOS-- and use a similar approach to Facebook, but the bulk of the code would be shared across the targets. I'm not entirely sure if SPM allows code shared across targets. A downside here is purely in terms of syntactic sugar-- naming differences. It seems unfortunate that you'd have to import say "MyLibrary_iOS" on iOS and "MyLibrary_macOS" on macOS.
2) Have a single target for iOS and macOS, but embed conditional compilation within the source code to conditionally include/exclude specific files. This doesn't have the naming issue as above. But it seems unclean to have to do this conditional compilation.
Any other suggestions?
Thanks!
Wait for the upcoming release of Swift 5.3. This has been added via SE-0273.

How to include libsignal-protocol-c in my Swift iOS app?

I would like to write something like import SignalProtocol at the top of one of my Swift files and then be able to call the C functions from libsignal-protocol-c.
libsignal-protocol-c's README says: "When integrating into actual applications, you should not need anything beyond CMake. Alternatively, you may integrate the code using a build system of your choice."
I think I'd like to use the Swift Package Manager to integrate libsignal-protocol-c into my Swift iOS app. Is there a way to automatically generate a manifest file, ie, Package.swift, and a module map, ie, a module.modulemap file, from libsignal-protocol-c's CMake files? Or if I need to create these files manually, what should they include? Otherwise, how would I do this with CMake?
How to import and use libsignal-protocol-c in an existing .xcodeProj? is a similar question but for Objective-C projects.
I'm not sure its an answer but I'm going to start using https://github.com/christophhagen/LibSignalProtocolSwift. Seems like a good start.

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

Basic Mechanics of iOS Frameworks and Xcode (and Swift)

I think I just must be stupid.
I'm having a lot trouble understanding very basic things concerning frameworks in Xcode/iOs/Swift. While I've certainly gotten some things to work, I've gotten more and more confused about what I'm actually doing. And the documentation on the web just confuses me more.
When I see discussions about how to import particular frameworks (e.g. https://github.com/danielgindi/Charts is the library I'm playing with, but I've seen this pattern repeated in other libraries) they seem to always tell me include the Xcode project file as a child project of my project, in addition to linking things as an embedded binary. This confuses me. Is it not possible to link an already compiled framework to my project without including all the source code of the project?
That is, can't I just take a library.framework file, and add it to my embedded libraries list and be done with it?
In the frameworks I've played with (again https://github.com/danielgindi/Charts is my primary example, but this is true in many others I've played with) I can't seem to use the framework without Carthage or CocoaPods. For me at this stage, that is just confusing... I accept that they are useful tools to automate a difficult process, but I'd really like to understand what that process actually is before I let a tool automate it for me. As I search the web I just seem to always be led back to these tools as being the correct way to do things.
So here are my questions.
If I find a framework library on the web... do I need its source code or can I somehow just link to a compiled version of the framework?
In my reading, it seems that libraries made with Swift are somehow second-class citizens because Swift is a newer thing. Is that still the case? (The articles I read about this seems to date from 2014-2015).
Is there are good place to understand how Apple expects me to add a framework to a project, without using CocoaPods or Carthage?
No need to add source code. Just add the framework to Target ->
General -> Linked Framework and Libraries -> Tap on + and select
your framework.
In my opinion, many new libraries are being written is Swift. So you won't be left behind for using swift.
Apple has documentation about adding frameworks to XCode. But I would suggest to use Cocoapods , as its easy to manage libraries.
Cheers :)

Resources