Search code examples
xamarinxamarin.iosmonoxamarin-linker

Xamarin iOS Linker fails on System.Net.Http.Primitives.dll


When building my Xamarin iOS (10.4.0.88) project for Release I get the following error when Link SDK assemblies only is enabled. I have Mono version 4.8.0.459

C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(694,3): warning : Aot files could not be copied to the destination directory /Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/obj/iPhone/Release/mtouch-cache/64/Build/Msym/Msym/tmp: Could not start process. 1> --- inner exception 1> System.ComponentModel.Win32Exception (0x80004005): ApplicationName='mono-symbolicate', CommandLine='store-symbols "/Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/bin/iPhone/Release/ServiceOrdersMobileAppsiOS.app.mSYM" "/Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/obj/iPhone/Release/mtouch-cache/64/Build/Msym/Msym/tmp"', CurrentDirectory='', Native error= Cannot find the specified file 1> at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0018b] in /private/tmp/source-mono-4.8.0/bockbuild-mono-4.8.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Diagnostics/Process.cs:737 1> --- 1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(694,3): warning : Aot files could not be copied to the destination directory /Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/obj/iPhone/Release/mtouch-cache/32/Build/Msym/Msym/tmp: Could not start process. 1> --- inner exception 1> System.ComponentModel.Win32Exception (0x80004005): ApplicationName='mono-symbolicate', CommandLine='store-symbols "/Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/bin/iPhone/Release/ServiceOrdersMobileAppsiOS.app.mSYM" "/Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/obj/iPhone/Release/mtouch-cache/32/Build/Msym/Msym/tmp"', CurrentDirectory='', Native error= Cannot find the specified file 1> at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0018b] in /private/tmp/source-mono-4.8.0/bockbuild-mono-4.8.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Diagnostics/Process.cs:737 1> --- 1> Process exited with code 1, command: 1> /Library/Frameworks/Mono.framework/Versions/Current/bin/mono /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/mono-cil-strip.exe /Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/obj/iPhone/Release/mtouch-cache/64/Build/System.Net.Http.Primitives.dll /Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/bin/iPhone/Release/ServiceOrdersMobileAppsiOS.app/.monotouch-64/System.Net.Http.Primitives.dll 1> Mono CIL Stripper 1> Error: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. 1> Parameter name: index 1> at System.Collections.CollectionBase.System.Collections.IList.get_Item (System.Int32 index) [0x00022] in <12e050e5b3d34326a1b4e2e7624e75da>:0 1> at Mono.Cecil.AssemblyNameReferenceCollection.get_Item (System.Int32 index) [0x00006] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.ReflectionReader.GetExportedTypeScope (Mono.Cecil.Metadata.MetadataToken scope) [0x00043] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.ReflectionReader.VisitExternTypeCollection (Mono.Cecil.ExternTypeCollection externs) [0x00089] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.AggressiveReflectionReader.ReadExternTypes () [0x0000c] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.AggressiveReflectionReader.VisitTypeDefinitionCollection (Mono.Cecil.TypeDefinitionCollection types) [0x0004f] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.ReflectionReader.VisitModuleDefinition (Mono.Cecil.ModuleDefinition mod) [0x00007] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.StructureReader.TerminateAssemblyDefinition (Mono.Cecil.AssemblyDefinition asm) [0x00034] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.AssemblyDefinition.Accept (Mono.Cecil.IReflectionStructureVisitor visitor) [0x0001f] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.AssemblyFactory.GetAssembly (Mono.Cecil.Binary.ImageReader irv, System.Boolean manifestOnly) [0x00014] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.AssemblyFactory.GetAssembly (Mono.Cecil.Binary.ImageReader reader) [0x00000] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.Cecil.AssemblyFactory.GetAssembly (System.String file) [0x00006] in <515b8343d4d0423f92114dba6b015690>:0 1> at Mono.CilStripper.Program.Main (System.String[] args) [0x00029] in <515b8343d4d0423f92114dba6b015690>:0 1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(694,3): error : Could not strip assembly /Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/obj/iPhone/Release/mtouch-cache/64/Build/System.Net.Http.Primitives.dll. 1> --- inner exception 1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(694,3): error : Could not strip assembly /Users/markmeyer/Library/Caches/Xamarin/mtbs/builds/ServiceOrdersMobileApps.iOS/295315d462497600265210bd6b0fdce2/obj/iPhone/Release/mtouch-cache/64/Build/System.Net.Http.Primitives.dll. 1> --- 1> at MonoTouch.Tuner.Stripper.Process (System.String assembly_file, System.String output_file) [0x000ba] in /Users/builder/data/lanes/3985/9975cb17/source/xamarin-macios/tools/mtouch/Stripper.cs:33 1> at Xamarin.Bundler.Target.m__2 (Xamarin.Bundler.Assembly assembly) [0x00065] in /Users/builder/data/lanes/3985/9975cb17/source/xamarin-macios/tools/mtouch/Target.cs:1041 1> at System.Threading.Tasks.Parallel+c__AnonStorey62[TSource,TLocal].<>m__0 (System.Int32 i) [0x00012] in <12e050e5b3d34326a1b4e2e7624e75da>:0 1> at System.Threading.Tasks.Parallel+<ForWorker>c__AnonStorey31[TLocal].<>m__1 () [0x000ed] in <12e050e5b3d34326a1b4e2e7624e75da>:0

I have the following additional mtouch arguments

-cxx -gcc_flags "-lc++" -v -v -v -v

If I turn off the linker everything builds and work fine. I need the linker to work to get my app approved by the app store as it strips out things I don't need (eg. CallKit). Any suggestions?


Solution

  • I've been experiencing the same problem and just found the solution. This appears to be a problem with the current beta versions of Xamarin iOS (10.4) and mono framework.

    Assuming that you're not on the stable channel of Xamarin:

    Open Xamarin Studio on the Mac and from the main menu click check for updates. Switch back to the stable channel and downgrade your Mono Framework and Xamarin iOS versions to the current releases.

    After doing so I was able to build app archive with linking enabled for release in the app store with Xamarin Studio.

    If you've been using the Visual Studio for Mac Preview, this version of the Mono Framework isn't compatible with it so you'll have to stick with Xamarin Studio or Visual Studio on Windows.