Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS app build fails when referencing package (e.g. Entity Framework Core 2.1) that depends on newer System.Memory #4168

Closed
cwrea opened this issue May 31, 2018 · 55 comments
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS
Milestone

Comments

@cwrea
Copy link

cwrea commented May 31, 2018

Steps to Reproduce

  1. Download, extract, and load the sample solution in Visual Studio 15.7.2.
    iOSEFCore21Soln.zip

  2. Build and run the project, targeting either iPhone or iPhone Simulator.

Expected Behavior

The project should build and run, writing some lines to debug output indicating that Entity Framework Core has created a database from the simple model included in the project.

Actual Behavior

The project won't build. The build fails with the following error:

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): error : Can't resolve the reference 'System.ReadOnlySpan1<System.Char> System.MemoryExtensions::AsSpan(System.String,System.Int32,System.Int32)', referenced from the method 'System.ReadOnlySpan1<System.Char> Microsoft.Extensions.Primitives.StringSegment::AsSpan()' in 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

EF Core v2.1 or one of its dependencies in turn depends on package System.Memory v4.5.0, while the build appears to be linking the app with v4.0.1.0 of the System.Memory assembly included in Xamarin.iOS.

The previous release of EF Core, v2.0.3, could be included in a Xamarin.iOS project without causing this problem. If you change the sample solution to refer to package Microsoft.EntityFrameworkCore.Sqlite v2.0.3 instead of v2.1, ithe project builds and the app runs as expected.

Environment

Microsoft Visual Studio Community 2017 
Version 15.7.2
VisualStudio.15.Release/15.7.2+27703.2018
Microsoft .NET Framework
Version 4.7.02556

Installed Version: Community

Visual C++ 2017   00369-60000-00001-AA398
Microsoft Visual C++ 2017

Add New File   3.5
The fastest and easiest way to add new files to any project - including files that start with a dot

Application Insights Tools for Visual Studio Package   8.12.10405.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.40511.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   15.7.31476
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2012   4.0.21208.0
For additional information, visit https://www.asp.net/

ASP.NET Web Frameworks and Tools 2017   5.2.60419.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.40424.0
Azure App Service Tools v3.0.0

C# Tools   2.8.2-beta6-62916-08. Commit Hash: 2ad4aabc7a9dada097e54e544ebba48ab1c05074
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

CodeMaid   10.4.53
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

JetBrains ReSharper Ultimate 2017.2.2    Build 109.0.20171006.122324
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2018 JetBrains, Inc.

Merq   1.1.19-rc (a4ffc1b)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.10.5-pre (ab58725)
Support for debugging Mono processes with Visual Studio.

Node.js Tools   1.4.11027.3
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager   4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Open Command Line   2.1.179
Opens a command line at the root of the project. Support for all consoles such as CMD, PowerShell, Bash etc. Provides syntax highlighting, Intellisense and execution of .cmd and .bat files.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

Search in Velocity by Silverlake Software LLC   0.7.1
Provides a command to search in Velocity the offline documentation and docset viewer for Windows

SQL Server Data Tools   15.1.61804.210
Microsoft SQL Server Data Tools

SQLite & SQL Server Compact Toolbox   4.7
SQLite & SQL Server Compact Toolbox adds scripting, import, export, rename, query execution and much more to SQL Server Compact & SQLite Data Connections.

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

TypeScript Tools   15.7.20419.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.8.2-beta6-62916-08. Commit Hash: 2ad4aabc7a9dada097e54e544ebba48ab1c05074
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.1 for F# 4.1   15.7.0.0.  Commit Hash: 56f97a8dd4353d897336941f3e644423b87c794f.
Microsoft Visual F# Tools 10.1 for F# 4.1

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Universal Windows Apps   15.0.27703.2018
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSColorOutput   2.5.1
Color output for build and debug windows - http://mike-ward.net/vscoloroutput

Windows Machine Learning Generator Extension   1.0
Windows Machine Learning Visual Studio Extension Detailed Info

Xamarin   4.10.0.448 (4373404db)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   4.12.270 (82d750d12)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK   8.3.0.19 (HEAD/342b2ce96)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.10.1.178 (408d357)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

1>------ Build started: Project: iOSEFCore21, Configuration: Debug iPhone ------
1>  Connecting to Mac server cwrea-mini...
1>  Connecting to Mac server cwrea-mini...
1>  No way to resolve conflict between "System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1>  No way to resolve conflict between "System.Reflection, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "System.Reflection, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1>  No way to resolve conflict between "System.Collections, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "System.Collections, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1>  No way to resolve conflict between "System.Diagnostics.Debug, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Diagnostics.Debug, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "System.Diagnostics.Debug, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1>  No way to resolve conflict between "System.Runtime.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "System.Runtime.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1>  No way to resolve conflict between "System.Threading, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Threading, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "System.Threading, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1>  Consider app.config remapping of assembly "System.Runtime, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll] to Version "4.0.20.0" [] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Collections, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Collections\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Collections.dll] to Version "4.0.10.0" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Collections.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Threading, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Threading\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Threading.dll] to Version "4.0.10.0" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Threading.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Diagnostics.Debug, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Diagnostics.Debug\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Diagnostics.Debug.dll] to Version "4.0.10.0" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Diagnostics.Debug.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Reflection, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Reflection\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Reflection.dll] to Version "4.0.10.0" [] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Runtime.Extensions, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Extensions\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.Extensions.dll] to Version "4.0.10.0" [] to solve conflict and get rid of warning.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.
1>  iOSEFCore21 -> D:\Projects\iOSEFCore21Soln\iOSEFCore21\bin\iPhone\Debug\iOSEFCore21.exe
1>  Detected signing identity:
1>    Code Signing Key: "iPhone Developer: [...] (...)" 
1>    Provisioning Profile: "cwrea iOS Dev Prov. Profile" (...)
1>    Bundle Id: com.companyname.iOSEFCore21
1>    App Id: J7ADM89KY9.com.companyname.iOSEFCore21
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): warning : The assembly 'System.IO.Compression.dll' was loaded from a different path than the provided path (provided path: /Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/9d38db02eb7af8d56c5be8ed8fd7f99b/bin/iPhone/Debug/System.IO.Compression.dll, actual path: /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/lib/mono/Xamarin.iOS/System.IO.Compression.dll).
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): warning : The assembly 'System.Net.Http.dll' was loaded from a different path than the provided path (provided path: /Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/9d38db02eb7af8d56c5be8ed8fd7f99b/bin/iPhone/Debug/System.Net.Http.dll, actual path: /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/lib/mono/Xamarin.iOS/System.Net.Http.dll).
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): warning : The assembly 'System.Runtime.InteropServices.RuntimeInformation.dll' was loaded from a different path than the provided path (provided path: /Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/9d38db02eb7af8d56c5be8ed8fd7f99b/bin/iPhone/Debug/System.Runtime.InteropServices.RuntimeInformation.dll, actual path: /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/lib/mono/Xamarin.iOS/Facades/System.Runtime.InteropServices.RuntimeInformation.dll).
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): warning : The assembly 'System.Security.Cryptography.Algorithms.dll' was loaded from a different path than the provided path (provided path: /Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/9d38db02eb7af8d56c5be8ed8fd7f99b/bin/iPhone/Debug/System.Security.Cryptography.Algorithms.dll, actual path: /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/lib/mono/Xamarin.iOS/Facades/System.Security.Cryptography.Algorithms.dll).
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): warning : The assembly 'System.Security.Cryptography.Encoding.dll' was loaded from a different path than the provided path (provided path: /Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/9d38db02eb7af8d56c5be8ed8fd7f99b/bin/iPhone/Debug/System.Security.Cryptography.Encoding.dll, actual path: /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/lib/mono/Xamarin.iOS/Facades/System.Security.Cryptography.Encoding.dll).
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): warning : The assembly 'System.Security.Cryptography.X509Certificates.dll' was loaded from a different path than the provided path (provided path: /Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/9d38db02eb7af8d56c5be8ed8fd7f99b/bin/iPhone/Debug/System.Security.Cryptography.X509Certificates.dll, actual path: /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/lib/mono/Xamarin.iOS/Facades/System.Security.Cryptography.X509Certificates.dll).
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): error : Can't resolve the reference 'System.ReadOnlySpan`1<System.Char> System.MemoryExtensions::AsSpan(System.String,System.Int32,System.Int32)', referenced from the method 'System.ReadOnlySpan`1<System.Char> Microsoft.Extensions.Primitives.StringSegment::AsSpan()' in 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Projects build report:
  Status    | Project [Config|platform]
 -----------|---------------------------------------------------------------------------------------------------
  Failed    | iOSEFCore21\iOSEFCore21.csproj [Debug|iPhone]

Time Elapsed 00:00:23.221

Example Project (If Possible)

iOSEFCore21Soln.zip

@therealjohn
Copy link
Contributor

I am able to still reproduce this with the sample on 15.7.3.

I see it may be resolved for XA (see dotnet/android#1769) already.

@spouliot I don't fully understand the problem here, but is there something done for XA with the facades that need to be done for XI too?

@therealjohn therealjohn added this to the Future milestone May 31, 2018
@cwrea
Copy link
Author

cwrea commented May 31, 2018

@therealjohn I confirmed the similar issue is resolved for Xamarin.Android with 15.7.3. I can also confirm I'm still seeing it as an issue on Xamarin.iOS with 15.7.3.

@jamiewest
Copy link

I am hitting this in iOS when referencing Microsoft.Extensions.DependencyInjection. Are there any workarounds until this gets fixed?

@leonvandebroek
Copy link

I was able to implement a workaround. I downgraden all package references for “Microsoft.extensions.*” to Version 2.0.0. In csproj file and PackageS.config

@cfdelaune
Copy link

@leonvandebroek this workaounrd does not appear to address my problem when attempting to run an iOS app on a device. I can compile, but get a "could not AOT the assembly..." error when I attempt to deploy.

Does anyone know if this is on the radar to be addressed in 15.7.4? I am hoping that EF Core 2.1 fixes a problem on iOS related to tables with more than 14 columns and/or nullable data types., but at this point I can't even get the app running on iOS to test.

@cwrea
Copy link
Author

cwrea commented Jun 6, 2018

Confirming @cfdelaune's comment. Downgrading package references for Microsoft.Extensions.* is not an effective workaround.

I tried on the sample project for this issue. In particular, I downgraded Microsoft.Extensions.Primitives to 2.0.0 in iOSEFCore21.csproj, which avoids requiring System.Memory 4.5.0:

<PackageReference Include="Microsoft.Extensions.Primitives">
  <Version>2.0.0</Version>
</PackageReference>

... however, when targeting a physical device, C# compilation succeeds, but the build fails during AOT with an assertion failure, "aot-compiler.c:3118, condition `t->num_mods == 0' not met":

1>  AOT Compilation exited with code 134, command:
1>  MONO_PATH=/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/Build /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/bin/arm64-darwin-mono-sgen --debug -O=gsharedvt -O=-float32  --aot=mtriple=arm64-ios,data-outfile=/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/arm64/Microsoft.EntityFrameworkCore.aotdata.arm64,static,asmonly,direct-icalls,full,soft-debug,dwarfdebug,no-direct-calls,outfile=/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/arm64/Microsoft.EntityFrameworkCore.dll.s "/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/Build/Microsoft.EntityFrameworkCore.dll"
1>  Mono Ahead of Time compiler - compiling assembly /Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/Build/Microsoft.EntityFrameworkCore.dll
1>  AOTID 009AF93F-42A4-41F7-02F9-8FDC36465855
1>  * Assertion at /Users/builder/data/lanes/5944/64fece5f/source/xamarin-macios/external/mono/mono/mini/aot-compiler.c:3118, condition `t->num_mods == 0' not met
1>  AOT Compilation exited with code 134, command:
1>  MONO_PATH=/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/Build /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/bin/arm64-darwin-mono-sgen --debug -O=gsharedvt -O=-float32  --aot=mtriple=arm64-ios,data-outfile=/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/arm64/Microsoft.EntityFrameworkCore.Relational.aotdata.arm64,static,asmonly,direct-icalls,full,soft-debug,dwarfdebug,no-direct-calls,outfile=/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/arm64/Microsoft.EntityFrameworkCore.Relational.dll.s "/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/Build/Microsoft.EntityFrameworkCore.Relational.dll"
1>  Mono Ahead of Time compiler - compiling assembly /Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/Build/Microsoft.EntityFrameworkCore.Relational.dll
1>  AOTID 9F48A88C-B8A2-1C27-0727-9CE918D2E9D8
1>  * Assertion at /Users/builder/data/lanes/5944/64fece5f/source/xamarin-macios/external/mono/mono/mini/aot-compiler.c:3118, condition `t->num_mods == 0' not met
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(791,3): error : Could not AOT the assembly '/Users/cwrea/Library/Caches/Xamarin/mtbs/builds/iOSEFCore21/e8ab617d17c8d48180dd2ebc14bac7aa/obj/iPhone/Debug/mtouch-cache/Build/Microsoft.EntityFrameworkCore.dll'

@cwrea
Copy link
Author

cwrea commented Jun 7, 2018

FWIW, this issue I opened is not just impacting users attempting to upgrade to Entity Framework Core 2.1, but is also a problem for users of SignalR on Xamarin: aspnet/SignalR #1886 - Xamarin support tracking issue. Quoting @davidfowl:

There's a bunch of work that is planned but that is also required to make SignalR work. There is an issue in System.Memory preventing it from being used in Xamarin applications. This issue is tracking the work that is being done in corefx to remedy the situation.

@cwrea
Copy link
Author

cwrea commented Jun 8, 2018

I tried another potential workaround, but still no luck.

The following claim was made in a comment on the .NET Standard issue at dotnet/standard#682 (comment):

The System.Memory package (which contains Span/Memory/etc) is available OOB (for full framework and older version of .net core (like 2.0), and it complies with netstandard1.1 so can be used on any of the platforms that meet netstandard1.1+ spec.

(Here's my own follow-up comment, for what it's worth.)

Anyway, I thought: Perhaps if I remove the Xamarin.iOS.framework copy of the broken System.Memory.dll facade, and then manually reference either netstandard1.1/netstandard2.0 versions of System.Memory and System.Buffers (required for the netstandard targets) in the iOS project, then maybe it will work.

But no success. With this attempted workaround, I still end up with the same "AOT Compilation exited with code 134" messages as when trying to downgrade Microsoft.Extensions.Primitives to 2.0.0.

@dgerding
Copy link

I just updated to latest nuget for XF 3.x and still get the error when (trying to) deploying to iOS real device. DOES run on iOS simulator.

I also need to stay on .net Core 2.1 for my EF and other bits since they helped resolve other problems. Anyone know the best way to ensure this is getting the attention it needs by the right folks? Seems like the problem is in System.Memory for Microsoft.Extensions.Primitives. At least it is for me.

System.MemoryExtensions::AsSpan(System.String,System.Int32,System.Int32)', referenced from the method 'System.ReadOnlySpan`1<System.Char> Microsoft.Extensions.Primitives.StringSegment::AsSpan()' in 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. LitFit.App.XF.iOS

@dgerding
Copy link

I reported via Visual Studio problem reporting under "System.MemoryExtensions related Build failure for iOS" - maybe if people "thumbs up" we can get more MS attention on problem?

@davidfowl
Copy link

The issue is know and is fixed in the latest patch which will be released very soon.

@dgerding
Copy link

Thanks @davidfowl. Fyi, I just again updating to very latest Microsoft.EntityFrameworkCore 2.11 nugets - but did not help (and also regressed Android build to a new compile-time error re System.Buffers). Which package should include the patch that should fix the problem? (And thanks again)

@cwrea
Copy link
Author

cwrea commented Jun 18, 2018

@dgerding The patch may be in reference to an upcoming maintenance release of Visual Studio + Xamarin, and not a NuGet package.

@Suriman
Copy link

Suriman commented Jun 19, 2018

@davidfowl. Do you mean version 15.7.4 of Visual Studio?

@emarchal78
Copy link

emarchal78 commented Jun 19, 2018

This is solve with VS2017 version 15.7.4 by updating EFCore v2.1.1 and all Microsoft.Extensions.* v2.1.1

UPDATE : I can only compile without error in Simulator configuration

@gi097
Copy link

gi097 commented Jun 19, 2018

I can confirm that this is NOT working on a physical iOS device using EFCore 2.1.1 and VS 15.7.4.

@cwrea
Copy link
Author

cwrea commented Jun 19, 2018

Potentially related: aspnet/Announcements#305:

ASP.NET Core 2.1.1 contains fixes to resolve blocking issues when using the SignalR Client from Xamarin. However, these fixes also require an updated build of Xamarin.iOS and Xamarin.Android, as well as some additional dependencies.

In addition to new packages for SignalR, it also mentions Visual Studio 15.8 Preview 3 with Xamarin.iOS 11.14.0.4 as needed to fully resolve the blocking issues. FWIW, an issue previously reported with SignalR on Xamarin.iOS also related to System.Memory.

Crossing my fingers this issue also gets resolved by VS 15.8 Preview 3.

@divega
Copy link

divega commented Jun 21, 2018

@smitpatel I think you tested EF Core 2.1 with the preview build. Did it all work?

@HelloMyDevWorld
Copy link

HelloMyDevWorld commented Jun 25, 2018

I've the same issue when i use EF 2.0.3 and SignalR 1.0.1 (System.ReadOnlySpan1<System.Char> ) on Xamarin.IOS

@dgerding
Copy link

Hi all (especially @cwrea :) ),
I just installed the new VS 15.8 Preview 3 build and I can report the I no longer get the "ReadOnlySpan" build error and I can run on the iOS simulator, which it wouldn't do before.

Yes, 15.8 P3 does update to a new Xamarin.iOS build, which VS for Windows did for me. Nice.

Unfortunately, I still can't get a build to deploy to real device. Think it's unrelated but thought people would want to know that 15.8 p3 does seem to fix the problem. I'll know for sure when I can deploy to a real device !

Dave G

Hooray!

@dgerding
Copy link

@cwrea Also, since my project also targets Android with EF2.1.1 I wanted to report that I don't get any System.Memory related errors on 15.8 Pre3 using latest release nugets. So it might have fixed the related issue, too.

@dgerding
Copy link

:( "Premature Hooray".

I couldn't get project to build to real device on my own system but wasn't getting memory related error. Just "app halted"... however, on an AppCenter hosted iOS build I see something familiar:

(_CompileToNative target) ->
MTOUCH : error MT2101: Can't resolve the reference 'System.ReadOnlySpan1<System.Char> System.MemoryExtensions::AsSpan(System.String,System.Int32,System.Int32)', referenced from the method 'System.ReadOnlySpan1<System.Char> Microsoft.Extensions.Primitives.StringSegment::AsSpan()' in 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

@HelloMyDevWorld
Copy link

Still nothing ?

@therealjohn
Copy link
Contributor

I no longer get the build error after installing the latest .NET Core version (2.1.2). I believe this PR fixed the issue.

Could someone else please confirm?

@smitpatel
Copy link

@therealjohn - That is correct. We have made fix to stop having build error in this case. If you are encountering any other error once you are past that, please file an issue in appropriate place so we can make things better.

@trevor-smith-nanotechsoftware-co-uk
Copy link

@ryl
Copy link

ryl commented Aug 12, 2018

I'm running into this problem trying to build for a real ios device. Has there been any progress on this problem?

Visual Studio Community 2017 for Mac
Version 7.5.4 (build 3)

Error MT3001: Could not AOT the assembly '.../Microsoft.EntityFrameworkCore.dll' (MT3001)

@cfdelaune
Copy link

I just gave this a shot using the latest stable bits (VS 2017 [15.7.6], NET STANDARD 2.0.3, EF 2.1.1, etc.) and run into the same issue as before.

Based on this thread, my hope is that these issues are resolved in VS 2017 [15.8] which I imagine will drop soon. I expect to be able to test as soon as it is released and will report back.

If anyone monitoring this thread has more information please let me know! Thanks.

@mandel-macaque mandel-macaque added the iOS Issues affecting iOS label Aug 13, 2018
@Diraekt
Copy link

Diraekt commented Aug 27, 2018

The build works fine for me in VS 15.8. I'm now able (after months...) to build on iOS successfully ;-).
But only on the simulator! If I build on a real device, I will recive the following error:

clang: error: linker command failed with exit code 1 (use -v to see invocation)
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): error MT5209: Native linking error: framework not found Carbon
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): warning MT5215: References to 'gdiplus' might require additional -framework=XXX or -lXXX instructions to the native linker
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): warning MT5215: References to 'gdi32' might require additional -framework=XXX or -lXXX instructions to the native linker
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): warning MT5215: References to 'user32' might require additional -framework=XXX or -lXXX instructions to the native linker
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): warning MT5215: References to 'libX11' might require additional -framework=XXX or -lXXX instructions to the native linker
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): warning MT5215: References to 'libcups' might require additional -framework=XXX or -lXXX instructions to the native linker
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): warning MT5215: References to 'gdiplus' might require additional -framework=XXX or -lXXX instructions to the native linker
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): warning MT5215: References to 'winspool' might require additional -framework=XXX or -lXXX instructions to the native linker
6>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(793,3): error MT5202: Native linking failed. Please review the build log.

@cfdelaune
Copy link

@Diraekt, using VS 15.8.1, I am (finally) able to compile and run on a physical iOS device.

The whole point of this for me has been to address the problem described here (allow tables with more than 14 columns and/or nullable types on iOS), which is unfortunately still not working.

@Diraekt
Copy link

Diraekt commented Aug 28, 2018

@cfdelaune thanks for your response. You think I will recive a Linker error at compile time because of your described problem? I think your described problem will cause a runtime exception. You have an idea why carbon framework is not founded when I build to a real device?
(Hard to understand, that nobody on iOS can use EF since months....)

@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Sep 3, 2018
@rolfbjarne
Copy link
Member

rolfbjarne commented Sep 3, 2018

I've tried the original test project [1], and while as-is it failed to build, it succeeded (both for device and simulator) after I upgraded the Microsoft.EntityFrameworkCore.Sqlite package from v2.1.0 to v2.1.2, so I'm closing this.

I did not see any of the MT5215 warnings reported in #4168 (comment); so if you see these (or any other problem for that matter), please file a new issue with a test project.

[1] With the current stable versions of Xamarin.iOS (11.14.0.14) & Mono (5.12.0.301)
Visual Studio Enterprise 2017 for Mac (Preview)
Version 7.7 Preview (7.7 build 1143)
Installation UUID: 5090bacd-da8d-4e67-8581-ba6c51620337
Runtime:
	Mono 5.12.0.301 (2018-02/4fe3280bba1) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

	Package version: 512000301

NuGet
Version: 4.3.1.4445

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.0.7
SDK: /usr/local/share/dotnet/sdk/2.1.105/Sdks
SDK Version: 2.1.105
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks

Xamarin.Profiler
'/Applications/Xamarin Profiler.app' not found

Apple Developer Tools
Xcode 9.4 (14160)
Build 9F1027a

Xamarin.Mac
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

Xamarin.iOS
Version: 11.14.0.14 (Visual Studio Enterprise)
Hash: d807bb8f
Branch: HEAD
Build date: 2018-07-25 09:04:12-0400

Xamarin.Android
Not Installed

Android Device Manager
Version: 7.7.1.0
Hash: c401ae7e

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 707001143
Git revision: 2ae7642c9d35b61b7973c964ed7a23f77b52a3ea
Build date: 2018-08-29 22:21:08+00
Build branch: release-7.7
Xamarin extensions: 118d45e2a9e7473c3df01e889009b3056e730adc

Operating System
Mac OS X 10.13.6
Darwin 17.7.0 Darwin Kernel Version 17.7.0
    Thu Jun 21 22:53:14 PDT 2018
    root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

@DoubleDBE
Copy link

When will this issue be fixed? I need it so badly to be fixed!

@divega
Copy link

divega commented Jun 23, 2019

@DoubleDBE to the best of my knowledge, this issue was already fixed. If you are seeing similar symptoms, consider creating a new issue and make sure you include the full details about how to repro, versions involved, and the exact error.

@NPadrutt
Copy link

@divega @DoubleDBE I have an IOS Application using version 2.2.4 which is working fine.

@trevor-smith-nanotechsoftware-co-uk
Copy link

@DoubleDBE
Copy link

DoubleDBE commented Jun 23, 2019

It's working fine on VS 2017. However on VS 2019 i'm getting this error #mysql-net/MySqlConnector#644

The moment Xamarin.iOS SDK v12.10.x is installed on my mac, i'm getting this error.

@trevor-smith-nanotechsoftware-co-uk
Copy link

@DoubleDBE
Copy link

I've edited my comment.

@ghost ghost locked as resolved and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS
Projects
None yet
Development

No branches or pull requests