While running my app, it's constantly looping a failed URL attempt:
2020-06-12 12:05:30.044721-0700 ERPXamarin.iOS[30657:2178586]
Task <75F8446B-3124-4986-B02B-1158F1AA798E>.<507> finished with error [-1] Error Domain=NSURLErrorDomain Code=-1 "unknown error"
UserInfo={
NSErrorFailingURLStringKey=https://reports.crashlytics.com/sdk-api/v1/platforms/ios/apps/com.perpetua.enroutepro3/reports,
NSErrorFailingURLKey=https://reports.crashlytics.com/sdk-api/v1/platforms/ios/apps/com.perpetua.enroutepro3/reports,
_NSURLErrorRelatedURLSessionTaskErrorKey=(
"BackgroundUploadTask <75F8446B-3124-4986-B02B-1158F1AA798E>.<507>"
),
_NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <75F8446B-3124-4986-B02B-1158F1AA798E>.<507>,
NSLocalizedDescription=unknown error
}
Just running my code with these 2 Firebase libraries installed causes the issue.
I found a few problems with this issue:
Looks like something went wrong in the background task to upload Crashlytics reports, but it's a generic (unknown) error. Are you using background tasks in your app at all?
No, only foreground tasks. We are only using Firebase for the crash reporting. We just converted from Fabric, and trying to do only as much as required for error reporting.
//Old crash reporting configs
//string apikey = "[...]";
//MonoTouch.Fabric.Crashlytics.Crashlytics.StartWithAPIKey(apikey);
//Firebase configs
var configuration = Configuration.SharedInstance;
App.Configure(); //<-- Including this line causes the the issue.
Crashlytics.Configure();
We have the same issue. We've setup a new project a few days ago. And we also configure Crashlytics for Xamarin.iOS.
Are either of you proxying your device's internet traffic?
No proxying. I've tried to enable Background Mode for iOS, but it didn't help.
This is the error I get:
An error occurred on the xpc connection to setup the background session: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.nsurlsessiond" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.nsurlsessiond}
An error occurred on the xpc connection to setup the background session: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.nsurlsessiond" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.nsurlsessiond}
Task <1F7A6FB0-F0F5-4761-A45E-724D9FE78F7B>.<18> finished with error [-1] Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo={NSErrorFailingURLStringKey=https://reports.crashlytics.com/sdk-api/v1/platforms/ios/apps/com.myapp/reports, NSErrorFailingURLKey=https://reports.crashlytics.com/sdk-api/v1/platforms/ios/apps/com.myapp/reports, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"BackgroundUploadTask <1F7A6FB0-F0F5-4761-A45E-724D9FE78F7B>.<18>"
), _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <1F7A6FB0-F0F5-4761-A45E-724D9FE78F7B>.<18>, NSLocalizedDescription=unknown error}
Ok. Referencing the Entitlements.info file for the iPhoneSimulator configuration fixed the issue for me (previously the file is referenced only for the iPhone configuration).
The content of the file is the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>com.myapp</string>
</array>
</dict>
</plist>
Are you able to reproduce this in a non-Xamarin setup? It seems like it may be a generalized entitlements issue.
Though it is definitely strange that missing a keychain access group entitlement is causing url session failures.
It was the same issue for us. The problem only happened on the simulator and there was no reference to the entitlements in the simulator section of the .csproj file.
So this fixed it for us:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
[...]
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
[...]
</PropertyGroup>
Our project is not set up for non-Xamarin project build, so I can't answer your question on that front.
I'm going to close this issue since it seems to be a Xamarin-only bug with a consistent and non-obtrusive workaround, but feel free to file a new issue if you run into any more Xamarin problems.
Most helpful comment
Ok. Referencing the
Entitlements.infofile for the iPhoneSimulator configuration fixed the issue for me (previously the file is referenced only for the iPhone configuration).The content of the file is the following: