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

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


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

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.

    <MtouchUseLlvm>false</MtouchUseLlvm>
    <MtouchEnableBitcode>false</MtouchEnableBitcode>
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.

Note You need to log in before you can comment on or make changes to this bug.