you can build a native library (iOS/mac support is experimental). you need to define the all the entry points as static [UnmanagedCallersOnly] methods . this limits the type of parameters, for example strings are not supported.
https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/interop
for c# to call the native library, you will need to use [DllImport] for the entry points. you could build an additional .net dll to expose c# callable methods.
for swift to call the library, you would need to create a c/c++ header file.
https://developer.apple.com/documentation/swift/using-imported-c-functions-in-swift
you can also create a swift package to wrap the library.
https://www.swift.org/documentation/articles/wrapping-c-cpp-library-in-swift.html