mono / Embeddinator-4000

Tools to turn .NET libraries into native libraries that can be consumed on Android, iOS, Mac, Linux and other platforms.
MIT License
758 stars 95 forks source link

Use more than one embedded library in a project: .NET Limitation #750

Closed amitkhoth closed 4 years ago

amitkhoth commented 4 years ago

I have two Queries For Embeddinator-4k

Query 1:

First is For Android Native App:

I Have an existing android Application project(Java) in which I have separate Plugin for Different Module. Ex. I have a android application which support Multiple Plugin.(Plugin are downloaded from internet after the app is installed on device) Main Application -> Plugin1, Plugin2, Plugin3 etc.

For Each Plugin Module I want to use separate .AAR create from Embeddinator tool. Can I use multiple .AAR for multiple plugin of same Application?

If not , What is reason behind this? or is there any Future Planning for the same?

Query 2: iOS App:

I have one workspace in Xcode in which I have Multiple Project for separate Module.

I want to use .Framework created from Embeddinator Tool . Can I use multiple .Framework for Separate project of same Workspace?

if yes , How i can achieve this? if Not, why is this Limitation ? or any Future Planning for the same?

Bitcode Limitation: Currently .NET Embedding does not support bitcode on iOS, which is enabled for some Xcode project templates. This will have to be disabled to successfully link generated frameworks.

Why is this Limitation? Please expalin.

whitneyschmidt commented 4 years ago

@amitkhoth Thank you for your feedback! The MS docs for E4K are a great reference for these types of questions: https://docs.microsoft.com/en-us/xamarin/tools/dotnet-embedding/

1 & 2:

You can use more than one embedded library in a project. You can use the generator to create a single library that includes several assemblies (from different projects).

The issue is that each embedded library contains its own mono runtime, and a project cannot have two mono runtimes. Building several assemblies into the same library results in only one mono runtime.

There's a bit more information on this here: https://docs.microsoft.com/en-us/xamarin/tools/dotnet-embedding/limitations

Bitcode:

E4K cannot support bitcode for iOS because Xamarin generated bitcode for iOS is inline assembly, not "real" bitcode. So Xcode can recompile the bitcode, but not optimize or modify it. Generating bitcode makes binaries larger, and leads to longer builds.

Adding E4K support for iOS bitcode would mean increasing size + build time for un-optimizable, inline assembly "bitcode".