3

I'm getting this error in the func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { URLSessionDataDelegate method:

error=Optional(Error Domain=NSURLErrorDomain Code=-1 “unknown error” UserInfo={NSErrorFailingURLKey=https://www.example.com/, NSLocalizedDescription=unknown error, NSErrorFailingURLStringKey=https://www.example.com/})

Very similar code works perfectly from an application, but I'm trying to write an Sharing App Extension which uploads to a webserver.

I'm using URLSessionConfiguration.background(withIdentifier:"...") same as my desktop application.

Why do I get erorr -1?

Whirlwind
  • 14,286
  • 11
  • 68
  • 157
jrwren
  • 17,465
  • 8
  • 35
  • 56

1 Answers1

1

I was missing the com.apple.security.network.client entitlement in the entitlements file.

https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html#//apple_ref/doc/uid/TP40011195-CH4-SW9

jrwren
  • 17,465
  • 8
  • 35
  • 56