将 xcode/android 个库编译成 PCL 以便在共享代码中访问

compiling xcode/android libraries into PCL for acces in shared code

我正在尝试使用第 3 方库编写应用程序。第 3 方已经为 Android 和 IOS 制作了独立的 API,但两者之间没有。我研究了 PCLs ,似乎共享代码必须用 C# 编写。我质疑是否可以将 Xcode/Java 库编译成 PCL 以便我可以在共享代码应用程序中调用。我想在我的系统细节代码中编写一个没有一堆系统定义的应用程序。我的最终目标是尽可能少地编写重复代码。

很遗憾,您不能那样做。即使库的结果 API 在两个系统上看起来相同,但在两个系统上它仍然是 "native",并且库仍然是两个独立的程序集。

您可以为此使用 Java and Objective-C libraries. This will give you a C# interface to access the native library. Then to use the library from shared (PCL) code, you will need to create a dependency service, that which will require you to create an interface in the PCL and then implement the interface on both platforms. In the platform implementation you can then normally access your generated library as expected. See the documentation on a step-by-step tutorial 的绑定。

如果两个系统上的库确实完全相同,您可以在两个平台上共享源代码文件 (Add -> Existing item -> Add as Link),或者只是将库包装到一个接口,然后使用它进行访问。