Xamarin iOS Could not AOT the assembly Microsoft.EntityFrameworkCore.Migrations.Migration - ios

We've added migrations to our xamarin forms project and ever since then we can't deploy it to an iOS device. It will run on the simulator fine but will fail with AOT errors on deploying to device.
It seems to be a fairly wide spread topic over the web but none of the ideas so far have made a difference. We're using EntityFrameworkCore v2.2.6 along with xamarin.forms v4.1.0.
I've tried adding the -v -v -v for more details on the build log but still just get:
Error Could not AOT the assembly '/Users/MyUser/Library/Caches/Xamarin/mtbs/builds/MyCompany.Mobile.iOS/8fcd0a31c7f6e1a671890e2462fe729f/obj/iPhone/Debug/mtouch-cache/3-Build/MyCompany.Data.Persistence.dll' MyCompany.Mobile.iOS
Any ideas what else I should try?

I haven't try these but it could fix your issue
IOS Build -> General -> and uncheck the option Incremental Build.
Disable LLVM.
Remove all unnecesary classes, methods from your MyCompany.Data.Persistence.dll so it wont generate heavy code.
Change Linking to Link All Assemblies

Xamarin.Android applications use a linker to reduce the size
The default value is SdkOnly
None: No linking will be attempted.
SdkOnly: Linking will be performed on the base class libraries only, not user's assemblies.
Full: Linking will be performed on base class libraries and user assemblies. For more details refer here.. Note: if you are facing an issue with linking such as
"GetAdditionalResourcesFromAssemblies" task failed unexpectedly. System.IO.FileNotFoundException: . Perhaps it doesn't exist in the Mono for Android profile?
then recheck your xamarin.Android project settings and set the below tag,
true
It Should Solve Your Problem.

Related

Xamarin.iOS - Linker behavior: Link All - Assets images removed

Has anyone experienced the images loaded in the Assets Catalog of a Xamarin.iOS project being removed when using the Linker behavior: Link All?
I have the following solution structure (simplified):
MyApp.csproj (shared code)
MyApp.iOS.csproj (iOS project)
Assets
And I compile with the following mtouch arguments:
--linkskip=MyApp --linkskip=MyApp.iOS
Besides the fact of the images not showing up, the rest of the app works flawlessly.
I am using Visual Studio 2022 version 17.2.5; Xamarin version 17.2.0.177
Update:
Interestingly, if I replace the Xamarin.Forms.Image implementations for FFImageLoading.CachedImage, the images are not affected by the LinkAll configuration.
Well, trying to create a reproducible sample I came across the problem.
Basically, the following line CachedImageRenderer.InitImageSourceHandler(), introduced when using FFImageLoading, was messing up with Xamarin.Forms.Images when the linker was set to LinkAll.
The documentation of FFImageLoading is not super clear on what this line is for, but removing it fixed the problem.

Autofac Build() throws exception on latest Xamarin iOS when Linker configured to Link All

After upgrading to Visual Studio 16.3.0 (Visual Studio for Mac 8.3.1805) Autofac throwns an exeception when doing builder.Build() in a project that previously worked:
The type 'Autofac.Features.Indexed.KeyedServiceIndex'2' does not
implement the interface 'Autofac.Features.Indexed.IIndex'2'
With this release of Visual Studio (and maybe earlier versions too), iOS is compiled using Mono 6.4.0.198 and I suspected that this might be what is introducing the braking change. Alternatively the linker behaves differently with the latest tool-chain. All I can say is that this used to work and now it doesn't.
Following these guidelines is not sufficient: Cross-Platform and Native Applications
To work around the issue, first make sure that Autofac is installed both in the iOS project, Android and the .NET Standard shared project, then choose one of these two options:
Set the linker to Don't link or Link Framework SDK's Only
Or, you can; add --linkskip=Autofac (case sensitive!) to the Additional mtouch arguments in iOS Build found in the iOS project properties.
Or, you can; create a Custom Linker Configuration file, which I btw think is the best option if you need linking. It's a little bit more work, but when using a Linker Description file the compiler will give you usable feedback when you build, if you've made a mistake like misspelling an assembly etc. Also, the Linker Description file has an identical format across Android and iOS.
Note: Option 2 and 3 will only increase your app size a small amount, as it will ensure that all of the Autofac assembly is included in your app package, while all other assemblies not specified as part of 2 or 3 will continue to be linked.
I assume that the needs for one of these work-arounds is an indication that Autofac is currently not linker safe.

How to fix Undefined symbol error in Xcode?

I am developing a React-Native application, which has both an Android and iOS version.
When working in Xcode, I have had several errors, which included duplicated files and Mach-O Linker errors.
Right now I'm struggling with the following error.
This is the complete log with the error.
I also append some screenshots of my configuration.
It's a bit hard to deduce the problem with the given info (I appreciate you have tried to give a lot info but even still the error is so vague, it can be caused by multitudes of things)
If I were you, I would do the following
Create a bran new react-native app (lets call it buildMyIosApp for example)
Build and run that
Observe it building for ios (building buildMyIosApp through xcode works)
Change the react and react-native versions on buildMyIosApp to be the same as your project
Re-build buildMyIosApp
Compare the project setup of buildMyIosApp to your project
Hopefully you would be able to find the issue that way.

Lexical or preprocessor issue in react native while building ios app <React/RCTUtils.h> not found

When I am trying to build my ios app in xcode, the build is failing due to lexical or preprocessor issue the error shows up like this
This was a problem specific to the react-native-device-info module.
For your specific case you may try v1.6.1 or higher (currently at 2.0 as of May 21, 2019) of the library and that should fix things for you.
For others interested more generally in the problem, this is a react-native library that uses native code, so it has an XCode project embedded within it for use in react-native after you run react-native link react-native-device-info. Unfortunately, the library was not including any directories in it's header search path, so it was of course unable to find the header files for the react-native objects it was using locally.
A library user proposed a change that fixed that problem for tvOS, and I extended the change to cover iOS as well, and now the library no longer generates errors like this for iOS or tvOS targets.
Perhaps someone with a similar issue may find the specific changes required for the fix useful in their projects

Couldn't get Xamarin projects working with Rider-EAP on OSX

I was really excited, when JetBrains launched the Project Rider-EAP. First thing I've tried was to get a Xamarin-iOS project to run in Rider-EAP, but it doesn't work out of the box.
Update 1: This issue is now listed as critical bug with fix in EAP 2: https://youtrack.jetbrains.com/issue/RIDER-618
1. Problem (fixed) Projects didn't load with the exception that Xamarin.iOS.targets could not be found.
I fixed this with a simple Symlink:
ln -s /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/ “/Applications/Rider EAP.app/Contents/lib/ReSharperHost/macos-x64/mono/lib/mono/xbuild/”
2. Problem
References are not loaded correctly. Therefore the whole syntax highlighting and everything beyond is broken.
See screenshot: References are not loaded correctly
I get the following error as well:
Error:null: Error initializing task MakeDir: Could not load file or assembly '/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Tasks.dll' or one of its dependencies
Switching the xbuild to mono 4.2.2 removes the error but not solves the problem.
PS: It seams that the references are loaded correctly for Xamarin Android projects.
Basic Xamarin Support like open and build is added with EAP 8 of Project Rider.
More advanced features will come with the next Builds and are tracked here: https://youtrack.jetbrains.com/issue/RIDER-1533

Resources