Monotouch Binding and FacebookSDK - c#

MonoTouch Binding refers to my Static Library, which uses FacebookSDK.
Сhain projects:
MonoTouch App -> MonoTouch Binding -> My Static Library -> FacebookSDK
When you add interfaces ApiDefinition, arise errors associated with FacebookSDK how to solve this problem? Maybe someone has already encountered this problem?
Error MT5211: Native linking failed, undefined Objective-C class:
_OBJC_CLASS_$_FBFriendPickerViewController. If '_OBJC_CLASS_$_FBFriendPickerViewController' is a
protocol from a third-party binding, please check that it has the [Protocol] attribute in its
api definition file, otherwise verify that all the necessary frameworks have been referenced and
native libraries are properly linked in. (MT5211)

Remove reference of current the Facebook SDK framework and add the Facebook SDK again by drag and drop it in framework folder.
This will add Facebook SDK path automatically.

Related

Problem with using OpenCV library in Android Dynamic Shared library and Xamarin.Forms

I'm trying to use the OpenCV library for android (native C++) with Xamarin.Forms application. I created a Dynamic Shared Library and its wrapper in C# that works when there is no OpenCV in the project.
Next, I configured my library project to use OpenCV and built it (without actually using OpenCV in my code). The build is successful, but now when I run my Xamarin application and call functions from c++, the bellow exception will be thrown:
System.DllNotFoundException: 'libMathFuncs.so assembly:<unknown assembly> type:<unknown type> member:(null)'
I followed the instructions described here, successfully created a .so file, and used it in Xamarin.Forms application. I wrote the whole process in my blog.
Then I did the following changes to my Dynamic Shared Library project configuration (in Visual Studio):
In General -> Use of STL : LLVM libc++ static library (c++_static) (also tried shared library)
In C++:
General -> Aditional Include Library: Add "PathToOpenCV\sdk\native\jni\include" (I also tried to add this
path to VC++ Directories -> External Include Directories)
set the Enable C++ Exceptions to Yes (-fexceptions)
set the Enable Run-Time Type Information to Yes (-frtti)
set the Precompile Header to Not Using Precompiled Headers
In Linker:
I tried two ways:
Way 1: I added "sdk\native\libs\arm64-v8a\libopencv_java4.so" to input -> Aditional Dependencies
Way 2:
Added "sdk\native\libs\arm64-v8a" to General -> Additional Library Directories and
Added "opencv_java4" to Input -> Library Dependencies
I didn't use any OpenCV in my code (Actually did at first, but remove them). The project is built successfully.
But now when the application calls the function from .so file, the above exception will be thrown.
I tried with or without changing the told flags, but the result was the same.
Note: For now I only intrested in ARM64
My Enviremont:
Visual Studio 2022
Xaramin.Forms (Android Only)
Target API Level: Pie 9.0 (android-28)
Android NDK: R23C
Target: Nokia 8.1 - Android 11
There is a code in GitHub that is similar to what I want to do. I compared the project configuration and code of this repo with my project but didn't find where I went wrong.

Xamarin.Forms App crashes on iOS when installed via Testlfight

Hello fellow developers!
I am developing a Xamarin.Forms App for android and iOS.
It works fine in Debug and Release mode on Android Emulators, Android Devices, iOS Emulators.
But there is a problem with iOS Devices. Directly deploying the Debug/Release Builds to a device works. But when I upload the app to the AppStore and install it via Testflight on my device, it crashes on startup.
From the console I can see following errors:
"System.MissingMethodException: Default constructor not found for type App.Views.Login"
"Default constructor not found for type ColorPicker.iOS.Effects.ColorPickerTouchEffectiOS"
The first one is related to my Login View, which has a default constructor and works fine in debug and release builds.
The second one is related to a nugget package.
My question is:
Why are the default constructors available in Debug and Release but not when i download the app via Testflight? And how can I fix this?
Linking behaviour is set to "Link all".
That's because when you use the Link all assemblies option you need to manually preserve the classes in your project and potentially mark out library code that isn't linker safe.
There is a Microsoft document specifically catering to this question : https://learn.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=macos
You could set your linker behaviour to Link SDK assemblies only temporarily while you manually get ready for a full link.
Preservin code:
When you use the linker it can sometimes remove code that you might have called dynamically either using System.Reflection.MemberInfo.Invoke, or by exporting your methods to Objective-C using the [Export] attribute and then invoking the selector manually.
In those cases, you can instruct the linker to consider either entire classes to be used or individual members to be preserved by applying the [Xamarin.iOS.Foundation.Preserve] attribute either at the class-level or the member-level. Every member that is not statically linked by the application is subject to be removed. This attribute is hence used to mark members that are not statically referenced, but that are still needed by your application.
Skipping Assemblies
It is possible to specify assemblies that should be excluded from the linker process, while allowing other assemblies to be linked normally. This is helpful if using [Preserve] on some assemblies is impossible (e.g. 3rd party code) or as a temporary workaround for a bug.
--linkskip=NameOfAssemblyToSkipWithoutFileExtension // Single assembly
--linkskip=NameOfFirstAssembly --linkskip=NameOfSecondAssembly // Multiple Assemblies
Hope this helps. Make sure you go through the MS doc for more details

How use a Xamarin.GooglePlayServices.Maps in Xamarin.Forms?

I need use Xamarin.GooglePlayServices.Maps in my Xamarin.Forms App. But I wrote all my pages in shared project (for example App) and I can instal Xamarin.GooglePlayServices.Maps only in android project (App.Android). Can I use this pakage (Xamarin.GooglePlayServices.Maps) in my shared project (App)?
Download "Xamarin.Forms.Maps" instead. It have Dependencies to "Xamarin.GooglePlayService.Maps" and more.
Like HeroesVII said, install the Xamarin.Forms.Maps for Xamarin.Forms. A code sample below for your reference.
The configuration process for displaying and interacting with a map on Android of Xamarin.Forms is:
Get a Google Maps API key and add it to the manifest.
Specify the Google Play services version number in the manifest.
Specify the requirement for Apache HTTP Legacy library in the manifest.
For mroe details of steps, you could check the MS docs.
You could download the source file from the link below.
https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/workingwithmaps/
I'd suggest you as #HeroesVII said you should try Xamarin.Forms.Maps, is more lightweight and simplistic. Either way if you want to stick to Xamarin.GooglePlayServices.Maps there shouldn't be any problem with it being in the standard project.
You can find and example here in this repo I created about two days ago.

MT5211: Native linking failed, undefined Objective-C class

I made a binding from a objective-c framework, it is working correctly but when I try to link my Xamarin.iOS project (Link Framework SDKs Only), I get this error
MTOUCH: Error MT5211: Native linking failed, undefined Objective-C
class: GLKView. The symbol '_OBJC_CLASS_$_GLKView' could not be found
in any of the libraries or frameworks linked with your application.
(MT5211)
In the microsoft documentation, says to add the [Protocol] attribute to the binding project.
I tried to add the attribute in the ApiDefinition.cs, first on top of the class and then before all methods and interfaces the classe have, with no success.
Link for the github repo
What am I doing wrong ?
I have try the same steps as you did , and downloaded the project you provided.It works on my VS for Mac.So ,I suggest you can creat a new blank bind libaray and copy the code into it then build it again.
I have uploaded my project to my gitHub.you can download it and have a try.
Demo

WPF Application Incorporating WinAPI (Win8) components

I have a WPF application which utilizes a handwriting control.
By using an
<InkCanvas></InkCanvas>
In my XAML, I was able to get the user's strokes, and turn them into text using the InkAnalysis class. However, this is strictly 32bit, and my requirements dictate a 64bit build.
Unable to find a 64bit compatible library, I looked into upgrading to .NET 4.5 and utilizing the Windows8 classes which are available to desktop apps (by also adding
<TargetPlatformVersion>8.1</TargetPlatformVersion> to the csproj file so that I could add the 'Windows' namespace references). Luckily, Windows.UI.Input.Inking is.
However, when I add the reference to Windows.UI.Input.Inking, I get a build error which states:
Unknown build error, 'Cannot resolve dependency to Windows Runtime type 'Windows.Foundation.Metadata.PlatformAttribute'. When using the ReflectionOnly APIs, dependent Windows Runtime assemblies must be resolved on demand through the ReflectionOnlyNamespaceResolve event.'
I have looked into the:
Windows.Foundation.Metadata.PlatformAttribute
And it seems to want an enum member, either:
Windows.Foundation.Metadata.Platform.Windows
or
Windows.Foundation.Metadata.Platform.WindowsPhone
This is a desktop application, so I would obviously choose to target Platform.Windows, but cannot figure out how to tell the compiler this.
How can I incorporate this Windows.UI.Input.Inking class into my WPF application? My end goal is simply to convert strokes from the inkcanvas into text, in a 64 bit environment.
I discovered that I was receiving this error due to the reference added to the:
Windows.UI.Input.Inking
library. It seems that the correct way to add reference to Windows 8/8.1 WinAPI components (from a non WinAPI application) is the following:
Add <TargetPlatformVersion>8.1</TargetPlatformVersion> to the csproj file
Add reference to the Windows library (this is the key - adding the specific lib, in this case, Windows.UI.Input.Inking, causes the build error)
Add the more specific (ex: Windows.UI.Input.Inking) reference in the actual file where the API is required
I am working on creating a NuGet package which will edit the csproj file, and add the Windows reference. I'll update this if/when it is completed.

Categories