As for now, my Xamarin Form App solution:
|___MyDomain.Mobile
|
|___MyDomain.Mobile.Android
|
|___MyDomain.Mobile.iOS
Using VS 2015, I'm able to build and deploy to simulator (6, 6s, 7, 7s, ipad, etc...) just fine. But when I tried to build and deploy to my iOS devices (iPad and iPhone) using a free provisioning profile, I got the following error:
2> Generated session id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2> Generated build app name: MyDomain.Mobile.iOS
2> Connecting to Mac server 10.0.0.131...
2> No way to resolve conflict between "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
2>I:\_VSWorkSpace\MyDomain.Mobile\MyDomain.Mobile\MyDomain.Mobile.iOS\Main.cs(21,30,21,31): warning CS0168: The variable 'e' is declared but never used
2> MyDomain.Mobile.iOS -> I:\_VSWorkSpace\MyDomain.Mobile\MyDomain.Mobile\MyDomain.Mobile.iOS\bin\iPhone\Debug\MyDomain.MobileiOS.exe
2> Detected signing identity:
2> Code Signing Key: "iPhone Developer: xxxxxxxxxxx@gmail.com (xxxxxxxxxxxxxx)" (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
2> Provisioning Profile: "iOS Team Provisioning Profile: xxxxxxxxxxxxxxxxxxxxxxxxxxx" (xxxxxxxxxxxxxxxxxxxxx)
2> Bundle Id: xxxxxxxxxxxxxxxxxxxxx
2> App Id: xxxxxxxxxxxxxxxxxxxxxxxxxxx
2>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(696,3): error : Failed to resolve "System.Configuration.ConfigurationException" reference from "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Build started.
Build FAILED.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
As for error, the Linker was set to the default option "Link SDK assemblies only". Trying "Don't Link" gave me the following error:
2> Generated session id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2> Generated build app name: MyDomain.Mobile.iOS
2> Connecting to Mac server 10.0.0.131...
2> No way to resolve conflict between "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
2>I:\_VSWorkSpace\MyDomain.Mobile\MyDomain.Mobile\MyDomain.Mobile.iOS\Main.cs(21,30,21,31): warning CS0168: The variable 'e' is declared but never used
2> MyDomain.Mobile.iOS -> I:\_VSWorkSpace\MyDomain.Mobile\MyDomain.Mobile\MyDomain.Mobile.iOS\bin\iPhone\Debug\MyDomain.MobileiOS.exe
2> Detected signing identity:
2> Code Signing Key: "iPhone Developer: xxxxxxxxxxxxx@gmail.com (xxxxxxxxxxxxxx)" (xxxxxxxxxxxxxxxxxxxxxxxxx)
2> Provisioning Profile: "iOS Team Provisioning Profile: xxxxxxxxxxxxxxxxxxx" (xxxxxxxxxxxxxxxxxxxxxx)
2> Bundle Id: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
2> App Id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2> AOT Compilation exited with code 1, command:
2> MONO_PATH=/Users/victornguyen/Library/Caches/Xamarin/mtbs/builds/MyDomain.Mobile.iOS/848068465550219d0aabc577444792b2/obj/iPhone/Debug/mtouch-cache/64/Build /Library/Frameworks/Xamarin.iOS.framework/Versions/10.3.1.8/bin/arm64-darwin-mono-sgen --debug -O=gsharedvt --aot=mtriple=arm64-ios,data-outfile=/Users/victornguyen/Library/Caches/Xamarin/mtbs/builds/MyDomain.Mobile.iOS/848068465550219d0aabc577444792b2/obj/iPhone/Debug/mtouch-cache/System.Configuration.arm64.aotdata,static,asmonly,direct-icalls,full,soft-debug,dwarfdebug,no-direct-calls,outfile=/Users/victornguyen/Library/Caches/Xamarin/mtbs/builds/MyDomain.Mobile.iOS/848068465550219d0aabc577444792b2/obj/iPhone/Debug/mtouch-cache/System.Configuration.dll.arm64.s "/Users/victornguyen/Library/Caches/Xamarin/mtbs/builds/MyDomain.Mobile.iOS/848068465550219d0aabc577444792b2/obj/iPhone/Debug/mtouch-cache/64/Build/System.Configuration.dll"
2> Mono Ahead of Time compiler - compiling assembly /Users/victornguyen/Library/Caches/Xamarin/mtbs/builds/MyDomain.Mobile.iOS/848068465550219d0aabc577444792b2/obj/iPhone/Debug/mtouch-cache/64/Build/System.Configuration.dll
2> AOTID 235E9A81-6AF1-63FB-1A9A-E60B79A8A7FA
2> Failed to load method 0x600019c from '/Users/victornguyen/Library/Caches/Xamarin/mtbs/builds/MyDomain.Mobile.iOS/848068465550219d0aabc577444792b2/obj/iPhone/Debug/mtouch-cache/64/Build/System.Configuration.dll' due to Could not resolve type with token 01000047 assembly:System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.Configuration.ConfigurationException member:<none>.
2> Run with MONO_LOG_LEVEL=debug for more information.
2> AOT of image /Users/victornguyen/Library/Caches/Xamarin/mtbs/builds/MyDomain.Mobile.iOS/848068465550219d0aabc577444792b2/obj/iPhone/Debug/mtouch-cache/64/Build/System.Configuration.dll failed.
2>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(696,3): error : Could not AOT the assembly '/Users/victornguyen/Library/Caches/Xamarin/mtbs/builds/MyDomain.Mobile.iOS/848068465550219d0aabc577444792b2/obj/iPhone/Debug/mtouch-cache/64/Build/System.Configuration.dll'
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
"Link all assemblies" option didn't result in any build error, but when I deployed my app, it was just a blank screen. I believe this was due to the "Default constructor not found for type MyDomain.Mobile.ViewModels.LoginViewModel" error, which I also got if I tried to build the project in this mode targeting simulator.
This only happens after I upgraded xamarin (to 2.3.2.127) and xcode (to 8.2.1), cause I wanted to test my apps on iOS 10.2. About a few months ago, I was working on another Xamarin Form app and didnt run into any of this kind of error when deploying to real iOS devices.
Initially, within the parent solution, I also had a MyDomain.Mobile.API project which is basically a web server where my app will make API calls to. This project does reference System.Configuration.dll, and uses System.dll version 4.0.0. My understanding is that when linking assemblies and packaging the final app to device, this API project should not interfere with the MyDomain.Mobile.iOS one (which uses another version of System.dll of 2.0.5.0) since it doesnt have any dependency to this MyDomain.Mobile.API. Regardless, since I ran into this System.Configuration reference issue, I went ahead and moved this API project to somewhere else (outside of this solution) and built the iOS one again (using all 3 linker options) just to see if it makes any difference. And it still gave me the exact same error.....
Could someone give me any pointer on how to fix this? Bottom line is that I cant seem to deploy to iOS devices; no problem for simulator.