Linking failed when using Hockey SDK in Xamarin IOS App - c#

I have a Xamarin.forms app. In the iOS project I installed the HockeyApp package from here and followed the samples here by adding the following code in my AppDelegate.cs:
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
//We MUST wrap our setup in this block to wire up
// Mono's SIGSEGV and SIGBUS signals
HockeyApp.Setup.EnableCustomCrashReporting (() => {
//Get the shared instance
var manager = BITHockeyManager.SharedHockeyManager;
//Configure it to use our APP_ID
manager.Configure ("YOUR-HOCKEYAPP-APPID");
//Start the manager
manager.StartManager ();
//Authenticate (there are other authentication options)
manager.Authenticator.AuthenticateInstallation ();
//Rethrow any unhandled .NET exceptions as native iOS
// exceptions so the stack traces appear nicely in HockeyApp
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
Setup.ThrowExceptionAsNative(e.ExceptionObject);
TaskScheduler.UnobservedTaskException += (sender, e) =>
Setup.ThrowExceptionAsNative(e.Exception);
});
//The rest of your code here
// ...
}
As soon as I try to compile the program Visual Studio throws the following error (and some more of that kind):
Severity Code Description Project File Line Suppression State
Error Native linking failed, undefined symbol:
std::__1::__vector_base_common::__throw_length_error() const.
Please verify that all the necessary frameworks have been referenced
and native libraries are properly linked in. App.iOS
When I comment that code piece everything runs fine.
Any suggestions on that? Anybody who successfully setup Hockey in an ios xamarin forms project?

Are you targeting iOS 6?
If so from the getting started section on the HockeyApp Component it states this:
Targeting iOS 6.0
If you would like your app to target iOS 6.0 you will need to add the following arguments to your application project settings.
Open project Options
Under Build -> iOS Build
Go to the Additional Options -> Additional mtouch arguments and add:
-cxx ->gcc_flags "-lc++"
Also this bug says the same thing

Related

Microsoft.AppCenter.Crashes not detecting crashes on Xamarin.Forms iOS project

I recently tried to implement Microsoft.AppCenter.Crashes to help track down crashes in my team's Xamarin.Forms app. However, when a crash happens on our iOS project, AppCenter never detects it. I've created the following function for setup and checking, which gets called near the start of our central project's App.xaml.cs App constructor:
private async Task CheckForPreviousCrash()
{
//Setup AppCenter
await Xamarin.Forms.Device.InvokeOnMainThreadAsync(() =>
{
//Keys changed in StackOverflow post for security reasons.
AppCenter.Start("ios=########-####-####-####-############;android=########-####-####-####-############;uwp=########-####-####-####-############", typeof(Crashes));
AppCenter.IsNetworkRequestsAllowed = false; //Prevents sending user data to Microsoft. Required by company
});
//Make sure AppCenter is working
bool isEnabled = await Crashes.IsEnabledAsync();
if (!isEnabled)
{
_logger.LogError("AppCenter could not be started");
}
else
{
//Check for memory leak warnings
bool memoryIssue = await Crashes.HasReceivedMemoryWarningInLastSessionAsync();
if (memoryIssue)
{
_logger.LogError("AppCenter detected a memory warning in the last session");
}
//Check for crash info
bool crashed = await Crashes.HasCrashedInLastSessionAsync();
if (crashed)
{
var report = await Crashes.GetLastSessionCrashReportAsync();
_logger.LogCrashReport(report);
}
//If AppCenter detected no issues in the last session, log an "all clear" message
if (!memoryIssue && !crashed)
{
_logger.LogInformation("AppCenter did not detect a crash in the last session");
}
}
}
I've tested this code using the Crashes.GenerateTestCrash() function, one of the crashes my team is trying to resolve, and a simple recursive function that calls itself forever. When run on iOS, our logs will always show the "AppCenter did not detect a crash in the last session" message, regardless of if a crash occurred. Any help determining what could be causing this would be appreciated.
Notes:
The iOS project is always run without a debugger attached. I'm aware of the rule that crash reports will not be generated if iOS has a debugger attached
This has been seen when built using both Debug and Release mode
This code works as expected on our Android and UWP projects
The iOS project always passes the isEnabled check
This is running AppCenter and AppCenter.Crashes version 4.5.0
This is running on a 7th gen iPad on iOS 15.2.1
EDIT: Extra notes in response to a suggested answer:
The Mac used to build the iOS project is running macOS 11.6.2
Project is built using XCode 13.2.1
The Xamarin Forms project is built in Visual Studio 2019 16.11.7, and sent to the connected mac via Visual Studio's "Pair to Mac" feature
There are no other libraries used for crash reporting (the closest used is Serilog, which should only be handling logging)
We do not use CocoaPods to integrate AppCenter
You can check if you meet the requirements as following shows:
-Your iOS project is set up in Xcode 11 or later on macOS version 10.14.4 or later.
-You're targeting devices running on iOS 9.0 or later.
-You're not using any other library that provides Crash Reporting functionality (only for App Center Crashes).
-If you are using CocoaPods to integrate App Center, you need CocoaPods version 1.10 or later.
App Center SDK Analytics and Crashes are compatible with Mac Catalyst via XCFramework or SwiftPM.
Here are more detail about appcenter crashed on ios https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/ios

Android FFImageLoading! exception: System.Exception: Please call CachedImageRenderer.Init method in a platform specific

I am getting this exception:
Unhandled Exception:
System.Exception: Please call CachedImageRenderer.Init method in a platform specific project to use FFImageLoading! occurred
The exception is occurring in external code and not code I can step through.
This exception only occurs in the Visual Studio Emulator for Android application.
But it works fine on a Samsung S8 phone.
My MainActvity code looks like:
protected override void OnCreate(Bundle savedInstanceState)
{
FFImageLoading.Forms.Platform.CachedImageRenderer.Init(false);
// etc
}
I have tried various versions of the FFImageLoading library. I am currently using the latest which is 2.4.7.944.
After trying a few different emulated phones with the VS Android emulator and seeing that they worked I uninstalled the one that wasn't working and reinstalled it. And now it is working properly. The only thing I can say is arrrrrgh!

Xamarin iOS - "Native linking failed for .." with Static Library Bind

I'm trying to build an, only iOS, app but I get two errors:
linker command failed with exit code 1 (use -v to see invocation)
Native linking failed for '/Users/{name}/Desktop/{application name}/{application name}/obj/iPhone/Debug/device-builds/iphone8.1-11.1.2/mtouch-cache/arm64/libSomething.dll.dylib'. Please file a bug report at http://bugzilla.xamarin.com
I get these errors with a dll generated from a binding of a (native obj-c) static library with XCode 9.2
I'm using Visual Studio 7.2 with Xamarin.iOS 11.6.1.2
I fixed it.
The error was in the Static Library, was missing two classes.
I've added these two in XCode and then works.

System.typeloadException while running VS code

I am a beginner in software development. I was following a simple tutorial and was creating a web application in Asp.net MVC - 5. But suddenly my app stopped running even I did not do any fancy stuff. Below is the error I am getting. Please help me here.
Error: System.typeloadexception.
Additional: Microsoft,Ajax.Utilities.OutputVisitor from assembly 'WebGrease'
I have not touched these fancy stuff at all. But as soon as I run the application in local host I start getting this error. Error comes in _Layout.cshtml file near the line
#Scripts.Render("~/bundles/modernizr")
This can happen if your targeted .Net framework version not installed on your System. Check your project properties .Net version and check your Pc has respective .Net installed.
try
{
}
catch (TypeLoadException)
{
// this can happen if respective .Net is not installed in your system
}
TypeLoadException is thrown when the common language runtime cannot
find the assembly, the type within the assembly, or cannot load the
type.
or add this code snippet
AppDomain.CurrentDomain.AsemblyResolve += (s, e) =>
{
return AppDomain.CurrentDomain.GetAssemblies()
.SingleOrDefault(asm => asm.FullName == e.Name);
}
If all attempts fails, try to reinstall WebGrease nugget package

Binding UIImageView invalid cast in Xamarin after upgrade

I recently tried to recompile a project that had been working in a newer version of Xamarin. The project compiles, but crashes on the device with an invalid cast exception.
System.InvalidCastException: Cannot cast from source type to destination type.
The crash occurs in designer generated code:
[MonoTouch.Foundation.Connect("turnOnAnimation")]
private MonoTouch.UIKit.UIImageView turnOnAnimation {
get {
object test = this.GetNativeField ("turnOnAnimation");
**this.__mt_turnOnAnimation = ((MonoTouch.UIKit.UIImageView)(this.GetNativeField("turnOnAnimation")));**
return this.__mt_turnOnAnimation;
}
set {
this.__mt_turnOnAnimation = value;
this.SetNativeField("turnOnAnimation", value);
}
}
Studying the return from GetNativeField, I seem to be getting a UIView instead of a UIImageView back:
But the outlet in the XIB is connected to a UIImageView.
To my knowledge this code was working fine with earlier versions. Has something changed in recent versions or should I be doing something differently?
Additional testing showed:
1) This problem occurred on an iPod touch running iOS version 7.1.1
2) The problem did not occur in the simulator running iOS 8.1 (any iOS platform)
3) The problem did not occur on an iPhone running 8.1.2
4) Upgrading the iPod touch to iOS 8.1.3 resolved the issue.
I conclude this was either an iOS bug or an incompatibility between current Xamarin tooling and the older version of iOS.

Categories

Resources