Created attachment 17978 [details]
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)
Note this problem doesn't occur on the parent iOS App project.
Disabling both bitcode and LLVM stops the error from occurirng, but these options are required to publish watchOS apps to the AppStore.
@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
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.
@rolf that issue should be already resolved in Mono 4.8
@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.