Bug 56498 - Native Code Sharing Disabled
Summary: Native Code Sharing Disabled
Status: RESOLVED FIXED
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: Production (addons.xamarin.com)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bill Holmes
URL:
: 56837 ()
Depends on:
Blocks:
 
Reported: 2017-05-16 12:53 UTC by kyle.spearrin
Modified: 2018-03-15 18:20 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description kyle.spearrin 2017-05-16 12:53:07 UTC
I was directed by one of the Xamarin.iOS team members to post this issue here.

Native code sharing is not working on my Xamarin Forms App + iOS Extensions.

See full output here: 
https://gist.githubusercontent.com/kspearrin/75742977e81b12420273e9f8f2a8ef42/raw/eb6fe4ebe431798d6860c1e1a0618e864f751106/ios%2520app%2520store%2520build2

In particular, I see this line happening:

Native code sharing has been disabled for the extension 'BitwardeniOSExtension' because the container app is referencing the assembly 'Google.Analytics' from '.../mobile/src/iOS/obj/iPhone/AppStore/XbdMerge/Google.Anal‌​ytics.dll', while the extension references it from '.../mobile/src/iOS.Extension/obj/iPhone/AppStore/XbdMerge/G‌oogle.Analytics.dll'‌​.

Full code repo to reproduce the issue can be found here: https://github.com/bitwarden/mobile
Comment 1 Rolf Bjarne Kvinge [MSFT] 2017-05-16 13:26:50 UTC
According to the log, Google.Analytics.dll is passed from multiple locations to mtouch:

[...]
obj/iPhone/AppStore/XbdMerge/Google.Analytics.dll
../../packages/Acr.Support.2.1.0/lib/Xamarin.iOS10/Acr.Support.iOS.dll
../../packages/Acr.UserDialogs.6.3.10/lib/Xamarin.iOS10/Acr.UserDialogs.dll
../../packages/Acr.UserDialogs.6.3.10/lib/Xamarin.iOS10/Acr.UserDialogs.Interface.dll
../../packages/BTProgressHUD.1.2.0.3/lib/Xamarin.iOS10/BTProgressHUD.dll
../../packages/Xamarin.FFImageLoading.2.2.9/lib/Xamarin.iOS10/FFImageLoading.dll
../../packages/Xamarin.FFImageLoading.Forms.2.2.9/lib/Xamarin.iOS10/FFImageLoading.Forms.dll
../../packages/Xamarin.FFImageLoading.Forms.2.2.9/lib/Xamarin.iOS10/FFImageLoading.Forms.Touch.dll
../../packages/Xamarin.FFImageLoading.2.2.9/lib/Xamarin.iOS10/FFImageLoading.Platform.dll
../../packages/Xamarin.Google.iOS.Analytics.3.17.0.1/lib/Xamarin.iOS10/Google.Analytics.dll
[...]

which is strange.
Comment 2 kyle.spearrin 2017-05-16 13:55:10 UTC
To be complete, I was having similar errors with Xamarin.Forms and some other packages whenever they existed in the host app projec, but not the Extension project. Whenever I referenced them in both projects from NuGet, those errors went away. Example:

warning MT0113: Native code sharing has been disabled for the extension 'BitwardeniOSExtension' because the container app is referencing the assembly 'Xamarin.Forms.Core' from '/Users/kyle/Projects/bitwarden/mobile/packages/Xamarin.Forms.2.3.4.231/lib/Xamarin.iOS10/Xamarin.Forms.Core.dll', while the extension references it from '/Users/kyle/Projects/bitwarden/mobile/src/App/bin/Release/Xamarin.Forms.Core.dll'.
Comment 3 kyle.spearrin 2017-05-16 14:05:41 UTC
Not sure if this has anything to do with it, but the Xamarin Google Analytics package for iOS has a dependency on Xamarin.Build.Download. Not really sure what that package does, but something involved with the build that may be screwing with things?

https://www.nuget.org/packages/Xamarin.Google.iOS.Analytics/
https://www.nuget.org/packages/Xamarin.Build.Download/
Comment 4 Rolf Bjarne Kvinge [MSFT] 2017-05-16 16:38:16 UTC
The "XdbMerge" is comes from here: https://github.com/xamarin/XamarinComponents/blob/8dc883172c4006423be47b3cb437e1952981d030/Util/Xamarin.Build.Download/source/Xamarin.Build.Download/BaseXamarinBuildResourceRestore.cs#L41

If I'm reading this [1] right, the idea is for Xamarin.Build.Download to rewrite the assembly, and change the old reference. For some reason it seems like the old reference isn't removed.

I'm re-assigning to the Components team: please bounce back if my diagnosis is incorrect.

[1] https://github.com/xamarin/XamarinComponents/blob/8dc883172c4006423be47b3cb437e1952981d030/Util/Xamarin.Build.Download/source/Xamarin.Build.Download/BaseXamarinBuildResourceRestore.cs#L52-L117
Comment 5 Rolf Bjarne Kvinge [MSFT] 2017-05-16 16:47:19 UTC
@Kyle, I've filed a different bug to allow code sharing for identical assemblies, even if paths are different: bug 56513. That should also fix your problem, even if this bug isn't fixed.
Comment 6 Bill Holmes 2017-05-23 20:40:24 UTC
I have changed Xamarin Build Download to write the dll back to the source location.  

https://github.com/xamarin/XamarinComponents/commit/8ea82525f9

This will ensure that the build is only considering one dll.

You will need to update Xamarin.Build.Downoad to 0.4.5.
https://www.nuget.org/packages/Xamarin.Build.Download/0.4.5
Comment 7 Rolf Bjarne Kvinge [MSFT] 2017-05-25 13:17:45 UTC
*** Bug 56837 has been marked as a duplicate of this bug. ***
Comment 8 Ilya Khorev 2018-03-15 18:17:02 UTC
Unfortunately, I have the same warning. However, I have the latest xamarin version installed and Xamarin.Build.Download 0.4.9

The warning looks as follows:

Users/ilya/Projects/Abc/Abc.xamarin/Abc.iOS.ShareExtension/bin/iPhone/Debug/Realm.dll'. (MT0113) (Abc.iOS)/Users/ilya.khorev/Projects/Abc/Abc.xamarin/Abc.iOS/MTOUCH: Warning MT0113: Native code sharing has been disabled for the extension 'AbciOSShareExtension' because the container app is referencing the assembly 'Realm' from '/Users/ilya.khorev/Projects/Abc/Abc.xamarin/Abc.iOS/bin/iPhone/Debug/Realm.dll', while the extension references a different version from '/Users/ilya.khorev/Projects/Abc/Abc.xamarin/Abc.iOS.ShareExtension/bin/iPhone/Debug/Realm.dll'. (MT0113) (Abc.iOS)

I've already tried to clear Xamarin cache and removed all bin, obj folder, nothing helped. Any ideas how to overcome this irritating issue?
Comment 9 Rolf Bjarne Kvinge [MSFT] 2018-03-15 18:20:56 UTC
@Ilya, please post this on GitHub (https://github.com/xamarin/xamarin-macios/issues/new) and include the complete build log.