简体   繁体   中英

Is it possible to compile a Xamarin project as a library for iOS and Android?

I need to create an API library for Android and iOS. I have experience working with Android projects, but zero experties in iOS. I was wondering if I could create a Project library in Xamarin that compiles as a JAR for Android and as an... I-don't-know-which-type for iOS.

No, that isn't possible. Depending on what you are trying to accomplish there may be alternatives. If you are trying to make a library that can be used by others you could make it a Xamarin component - there is a component store you could put it on if you want it to be generally available, otherwise you can use any normal means of source or object distribution.

If you need to interact with a native app/library then you could make the C# code the "owner" of it and have it call into the native code. This works for both IOs and Android (and is used to work with eg the play services from google).

不,很遗憾,这不可能。

It seems to me that what you need is a Portable Class Library also known as PCL . It allows you to create a project which can be referenced by all Xamarin supported platforms (such as iOs and Android). There are obviously limitations to the approach like not being able to reference platform specific libraries but in your case (of writing an API) it should suffice. You can read more in this link

Good Luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM