Xamarin iOS native linking failed for grpc.core - c#

I've been attempting to make grpc work (ssl http2) on Xamarin Forms and after some pain I managed to get it to work on Android using Grpc.Core. However I couldn't get iOS to compile. Working through this problem I was trying to get anything grpc related to work on iOS, and eventually found the grpc experimental xamarin demo, HelloworldXamarin. Found here:
https://github.com/grpc/grpc/tree/master/examples/csharp/HelloworldXamarin
I downloaded the solution, but when I try to compile it I get the following errors:
Error Text:
Native linking failed, undefined symbol: operator delete(void*). Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
Native linking failed. Please review the build log and the user flags provided to gcc: -LC:/g/examples/csharp/HelloworldXamarin/packages/Grpc.Core.2.23.0/build/Xamarin.iOS10/../../native/ios/universal -lgrpc_csharp_ext -force_load C:/g/examples/csharp/HelloworldXamarin/packages/Grpc.Core.2.23.0/build/Xamarin.iOS10/../../native/ios/universal/libgrpc_csharp_ext.a -LC:/g/examples/csharp/HelloworldXamarin/packages/Grpc.Core.2.23.0/build/Xamarin.iOS10/../../native/ios/universal -lgrpc -force_load C:/g/examples/csharp/HelloworldXamarin/packages/Grpc.Core.2.23.0/build/Xamarin.iOS10/../../native/ios/universal/libgrpc.a
linker command failed with exit code 1 (use -v to see invocation)
For the warning regarding not being able to find libgrpc_csharp_ext.a, I verified that the file was there.
There appears to be some issue with native linking, which I am very unfamiliar with. I'm using nearly the latest Visual Studio (well, 16.5.3), a mac build host with latest OS and XCode updated to latest. Didn't make any changes to the files pulled from git. I only just started working with Xamarin iOS this week, so everything should be in a fairly "default" state.
What could be wrong with my setup/system that makes this not work? I understand that this is an experimental feature still, but I can't tell if I've done something stupid or if there's been some change in something (like XCode? or it needing VS 2017?) that makes this no longer work? Is anyone else able to get this example to compile?
I've also tried newer versions of the grpc nuget packages and that only resulted in more errors.
Ultimately I'm trying to get latest Grpc.Core to work in iOS on Xamarin.Forms, though I have very little experience working with iOS. If there are issues with the latest versions of XCode/Visual Studio/Grpc.Core that are causing this, I'm willing to try to work through them, if someone can point me in the right direction.

It is not at all related to your versions or something that you did or didn't do.
First for some theory:
If someone wants to use Objective-C libraries or CocoaPods packages in their Xamarin project, they will need to create a binding library for this. Take it as some sort of a "bridge" between the native implementation and the later exposed C# code that you can use. You can learn more about the binding from the official documentation here and more specifically here.
To sum up the info - after the bindings have been created, you see a .lib or .a file. This is exactly what they have done - exposed some native code into the libgrpc_csharp_ext.a. Unfortunately, there are some bindings that are not correct. This is exactly what you are seeing here - the aftermath of an incorrect binding.
Looking a bit into the project I got to the following conclusions:
There is an open issue from May 2019 about this - https://github.com/grpc/grpc/issues/19172
Unfortunately, the issue is still active and there is no movement there.
I have confirmed that after version 1.21 (incl.) the build is not working. For now, you can downgrade to version 1.20.1 (last known to work). I have successfully built the solution with it. Please review the changelog and release notes for this specific version (if any) so that you know if it will fit your needs.
Basically, you have 2 options:
Downgrade to the last good version in order to use it;
If you want to use the latest version either wait for the issue to be fixed, or fork the repo and help with the fixing.
If you want to see their build script and help fix the issue, you can start from here.
Another useful resource is this video from the official Xamarin channel.

Related

Xamarin Android Linker Error when Linking is On, and Unspecific error when Linking is Off

In my visual Studio i have reached a point for my Xamarin Forms project, where i cannot build it, neither in debug or release mode.
In release mode, Linking on my Android project is set to "Sdk Assemblies Only". Having it set to this, i get following error.
I have tried setting linking to "None", like it is in debug mode, but that just causes a seperate list of error, which is even more confusing.
The errors in the image above, are in total 11 errors in Visual Studio.
These errors arouse after i had to increase the targeted Android version from 9 to 10, to support Googles Api requirement for new apps on Google Play. The updateing of Xamarin Form from version 4.4.0.936621-pre1 to 4.8.0.1560, might also have had an effect. Prior to changeing the targeted android version, it did however build just fine in debug mode, even with the higher Xamarin Forms version.
I am using Visual Studio Enterprise 2019 version 16.7.6, at the moment, if that is any help.
I have also implemented option A of the Workaround in the following link, to avoid the bug that the link talks about. This is another thing i thourght were good to mention, incase it has any effects on the result. Bug Workaround
Take note that the secound set of errors mentions a file called "proguard.cfg". That file does exist at the mentioned location. What is confounding is why it is mentioning that file, as i have not set Code Shrinker on the android project to anything, ie it is blank.
It is not a necessity to solve both sets of errors. That said, solving the first one, might simply mean that is also shows the secound set of error in the scenario where it is currently showing the first error. Because of this, it would be ideal to solve both errors, but at minimum the secound one.
Feel free to ask for more information. I can howerver not supply a packaged solution, with the errors, as it is for a company project, where i am not allowed to disclose the code. I tried to include the errors as text, but StackOverflow, sees it as code and therefore expects a specific formationg. Feel free to ask for it in text, if you need it, and i will try to supply it.

UWP : PRI277: 0xdef00532 - Conflicting values for resource ''

As a part of the Visual Studio 2017 UWP build process, an app called MakePri.exe is run. It is throwing an error in my project but I have no idea why. The command line call is:
C:\Program Files (x86)\Windows
Kits\10\bin\10.0.16299.0\x64\MakePri.exe New -ProjectRoot
C:\AdaptSource\src\Xivic\Adapt.Presentation.XamarinForms\Adapt.Presentation.Xivic.UWP\
-ConfigXml obj\x86\Debug\priconfig.xml -OutputFile C:\AdaptSource\src\Xivic\Adapt.Presentation.XamarinForms\Adapt.Presentation.Xivic.UWP\bin\x86\Debug\resources.pri
-IndexName AdaptSolutionsPty.Ltd.Xivic-Helpdesk -Verbose -Overwrite
The error that it returns is:
error PRI175 : 0x80073b0f - Processing Resources failed with error :
Duplicate Entry.
GENERATEPROJECTPRIFILE : error PRI277: 0xdef00532 - Conflicting values
for resource ''
I have no idea what it is talking about. There is no useful information in the error message. After sifting through a lot of google results, I see that the problem seems to come up when there are references to certain or duplicate DLLs in referenced .NET Standard / PCL projects.
For example:
https://forums.xamarin.com/discussion/103956/strange-build-error-xamarin-uwp
UWP unit test compile errors
But in other threads, at least people are getting a resource name to work with. I've removed as many references as I can. I've used resharper to help. I really need to get a useful error message out of MakePri. Does anyone know anything about this? Is there a way to see what it is stumbling on?
Edit: The issue was that my solution was using two versions of Xamarin.Forms. Once I consolidated the NuGet packages, the problem went away. But, I feel like this is a bug because the error message should be more descriptive. It wastes a lot of time. So, I've logged the issue here:
https://github.com/dotnet/buildtools/issues/1912
I'll leave this open until there is some kind of response at Microsoft.
Consolidate both Xamarin.Forms and Microsoft.NETCore.UniversalWindowsPlatform version for all the dependency projects will resolve the issue. It is mainly due to the Xamarin.Forms latest stable version requires higher version of Microsoft.NETCore.UnivesalWindowsPlatform nuget i.e.,(6.0.1).
The message is missing a piece, may caused by 16299 sdk
please try use 15063 and you may get the right key
I had the same problem, with the exact same error message. My fix was different than yours.
By deleting resources one at a time, until the build succeeded, i found the cause to be in one of my language .resw files I had forgotten to append .Text to the name.
Language A:
"Message.Text", "Hello world"
Language B:
"Message", "Hello world"
This oversight gave me the error you mention in the heading.
The fix for me was to append .Text so the names are identical.

Install Microsoft.AspNet.Identity.EntityFramework.3.0.0-rc1-final into Class Library

I'm trying to create a class library for the new Microsoft Identity model but am being beaten back by an odd error.
If I create a regular C# Class Library (not a PCL) and attempt to install Microsoft.AspNet.Identity.EntityFramework.3.0.0-rc1-final via Nuget it goes so far, chokes, rolls back and then displays the following error:
Failed to add reference to 'System.Runtime'. Please make sure that it
is in the Global Assembly Cache.
I know that this is a pre-release version of the library but this cannot be such a radical idea that I'm trying to achieve here.
Any pointers greatly appreciated.
It seems to be a known issue and confirmed by Microsoft. It leads to this NuGet issue.
A workaround, according to the comments, is to install Microsoft.AspNetCore.Identity.EntityFrameworkCore, which is the RC2 equivalent. From what I can find this hasn't been officially released yet, and you might need to build from source.

How do you configure C# projects to build using Windows SDK 7.1 tools?

We're trying to switch a lot of projects over to use SDK7.1. This seems pretty straightforward with C++ projects, and you can change the 'Platform Toolset' property in the project settings to "Windows7.1SDK" and all is good.
But, with C# projects, (if you put the build output up to diagnostic mode), we can see that various tools such as sgen, resgen, LC, run from within a previous SDK 7.0A directory. Or, on some machines that we installed Vistual Studio 2012 on, some of these tools come from an v8.0A SDK folder.
Mismatches between the tools and the assemblies they produce seem to be causing various errors such as:
LC : error LC0000: 'Could not load file or assembly
'S:\Libraries\Bin\Release\Some.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.'
It seems we can edit the .csproj files and almost ad-hoc, and BeforeBuild etc targets that redefine various SDKPath properties. This seems to force the right tools to be used. But, if feels very 'hacky'. And we must be missing setting something as we still get some errors.
Alternatively, we've found, we can change the registry value here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0\SDK40ToolsPath
to point at the correct SDK. But, it feels wrong to have to modify the environment to support this. We want to build old versions of our product, and having to switch the environment around to do this is ugly and error prone.
Is there any official way of doing this?
Thanks.
P.S. I found this question http://social.msdn.microsoft.com/Forums/en-MY/windowssdk/thread/ebc8914f-d4b5-44e7-8c76-10332d155812 where the poster seems to be asking a similar thing, but, the question didn't seem to get answered.
The following two articles talk about defining custom tool sets. Perhaps one of those needs defining for the 7.1 SDK, and then MSBuild can be directed to use it.
http://msdn.microsoft.com/en-us/library/bb383796(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/bb397428.aspx

Are there any known compatibility issues with Microsoft Media Platform: Player Framework (formerly SMF) and Silverlight 5?

I'm trying to get the default template (adaptive streaming) for the MMPPF framework to work.
Currently I'm not getting any error, but the player does not play any videos. I've tried adding other sources besides the default, I can see them added in the playlist, but they won't play either.
Using Fiddler I can see that the player does not even attempt to retrieve the manifest (or anything else).
The online example here works fine, I've even tried using that manifest as a source, but it still won't play when I run it in Visual studio.
So my question, could this have anything to do with having Silverlight 5 toolkit installed? I would assume that the MMPPF/SMF template is supposed to work out of the box (which is also stated on the Codeplex site). Or is there something else I'm missing?
You may need to add some references to your project. MMPPF is using MEF to resolve plugins at run-time, and it can fail silently if it doesn't find a suitable plugin.
For Smooth Streaming, you need both Microsoft.SilverlightMediaFramework.Plugins.SmoothStreaming and Microsoft.Web.Media.SmoothStreaming for it to work for instance.
Update:
I've encountered another reference issue when migrating a project. I had to remove and re-add System.ComponentModel.Composition, then add System.ComponentModel.Composition.Initialization.
I tried to uninstall the Smooth Streaming Client that the MMPPF client installed and installed the newest from here, added a reference to the new dll (Microsoft.Web.Media.SmoothStreaming.dll) and everything worked.

Categories