Bug 45270 - Cannot add System.Reactive to watchOS Extension project
Summary: Cannot add System.Reactive to watchOS Extension project
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler ()
Version: XI 10.0 (iOS10)
Hardware: PC Mac OS
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Zoltan Varga
Depends on:
Reported: 2016-10-11 08:11 UTC by Jahmai
Modified: 2016-10-14 07:25 UTC (History)
4 users (show)

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

Reproduction solution (27.00 KB, application/zip)
2016-10-11 08:11 UTC, Jahmai

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:

Description Jahmai 2016-10-11 08:11:12 UTC
Created attachment 17978 [details]
Reproduction solution

Creating a brand new iOS + watchKit 3.0 solution, adding System.Reactive v3 to the watchKit extension project, and try to compile Release|Device configuration results in the following error:

/Users/Jahmai/Projects/RxAOT/RxAOT.RxAOTWatchExtension/CSC: Error CS1703: An assembly `System.Runtime.InteropServices.WindowsRuntime' with the same identity has already been imported. Consider removing one of the references (CS1703) (RxAOT.RxAOTWatchExtension)

This is probably a packaging issue relating to the target project type.

After manually removing the reference, the following error occurs, which is the more significant issue:

/Users/Jahmai/Projects/RxAOT/RxAOT.RxAOTWatchExtension/MTOUCH: Error MT3001: Could not AOT the assembly '/Users/Jahmai/Projects/RxAOT/RxAOT.RxAOTWatchExtension/obj/iPhone/Release/mtouch-cache/Build/System.Reactive.Core.dll' (MT3001) (RxAOT.RxAOTWatchExtension)

/Users/Jahmai/Projects/RxAOT/RxAOT.RxAOTWatchExtension/MTOUCH: Error MT3001: Could not AOT the assembly '/Users/Jahmai/Projects/RxAOT/RxAOT.RxAOTWatchExtension/obj/iPhone/Release/mtouch-cache/Build/System.Reactive.Linq.dll' (MT3001) (RxAOT.RxAOTWatchExtension)
Comment 1 Jahmai 2016-10-11 08:37:05 UTC
Note this problem doesn't occur on the parent iOS App project.
Comment 2 Jahmai 2016-10-11 08:40:11 UTC
Disabling both bitcode and LLVM stops the error from occurirng, but these options are required to publish watchOS apps to the AppStore.

Comment 3 Rolf Bjarne Kvinge [MSFT] 2016-10-11 17:53:03 UTC
@Marek, can you weigh in to check where the problem is with the compilation failure?

Build log showing compilation failure: https://gist.github.com/rolfbjarne/813d9139b86513cf037039580a389603

> 	CSC: error CS1703: An assembly `System.Runtime.InteropServices.WindowsRuntime' with the same identity has already been imported. Consider removing one of the references

Build log showing AOT failure: https://gist.github.com/rolfbjarne/04b0750d645fbbe100eef784fc0bda71
Comment 4 Zoltan Varga 2016-10-11 20:08:25 UTC
The AOT failures should be fixed on mono master/4.8 branch, the fixes will be in a future alpha version. As for using reactive extensions on watchos, watchos is a very resource constrained environment, so using simple imperative code would probably be better.
Comment 5 Marek Safar 2016-10-12 13:55:05 UTC
@rolf that issue should be already resolved in Mono 4.8
Comment 6 Jahmai 2016-10-14 07:25:32 UTC
@Zoltan Xamarin promotes code reuse across all platforms. Some of our shared code depends on System.Reactive. The AOT compiler should strip out unused code to reduce deployable binary size (it would have stripped out almost all of it if it didn't break). We worked around this particular issue by cherry picking our shared code ad-hoc into the watch extension, but this is not maintainable or desirable. These are portable shared libraries too, we don't create platform specific shared libraries since netstandard was supported, hence why this issue is important to fix.