Sharing PDF file from Safari with Action Extension failing in Swift 4.2 Xcode 10

I am writing an app with the "App Groups" capability enabled. The Action Extension in this app is open to PDF files and is available when a web page loaded in Safari is opened in reader mode and then converted to PDF.


In short, the app can take in the Webpage converted to PDF file from Safari. It was working alright before upgrading to Swift 4.2. Ever since downloading Xcode 10, it has stopped working with the following error:



(Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type com.adobe.pdf" 
UserInfo={NSLocalizedDescription=Cannot load representation of type com.adobe.pdf, 
NSUnderlyingError=0x600002dd9a70 {Error Domain=NSPOSIXErrorDomain Code=22 
"Invalid argument" UserInfo={NSLocalizedDescription=Cannot issue a sandbox extension for file 
"/Users/***/Library/Developer/CoreSimulator/Devices/FE5463C2-FAA3-41A9-938B-C1C234EA966A/data
"/Containers/Data/Application/B6FB42C6-B4E3-46D8-B9F9-5856FF88F0B6/tmp//Safari - Sep 22, 2018 at 10:00 PM.pdf": 
Invalid argument}}})


Can anyone throw some light on what is happening? Both the app and its action extension belong to the same App Group. The Action Extension has the following entries in the info.plist:


  NSExtensionAttributes
  
  NSExtensionActivationRule
  
                SUBQUERY (
                extensionItems,
                $extensionItem,
                SUBQUERY (
                $extensionItem.attachments,
                $attachment,
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" ||
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url"
                ).@count == $extensionItem.attachments.@count
                ).@count == 1
            
  
  NSExtensionMainStoryboard
  MainInterface
  NSExtensionPointIdentifier
  com.apple.ui-services

Maybe to clarify, I am getting the error at the point where I am loading the item from NSItemProvider


provider.loadItem(forTypeIdentifier: kUTTypeData as String, options: nil, completionHandler: { (data, error) in

guard error == nil else {

print(error)

return

}

//Do stuff with data

})


The data varilable is always received as nil and the error value is:


Optional<Error>

- some : Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.data" UserInfo={NSLocalizedDescription=Cannot load representation of type public.data, NSUnderlyingError=0x600001a85ad0 {Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedDescription=Cannot issue a sandbox extension for file "/Users/xxxx/Library/Developer/CoreSimulator/Devices/FE5463C2-FAA3-41A9-938B-C1C234EA966A/data/Containers/Data/Application/B6FB42C6-B4E3-46D8-B9F9-5856FF88F0B6/tmp//Safari - Sep 25, 2018 at 9:22 PM.pdf": Invalid argument}}}


Any idea, anyone?

Did you find a fix for this yet, i think we are seeing the same issue. I just opened a ticket with apple.

Looks like this is broken behavior coming from Safari. As of today, I cannot share anything from Safari (my app will not show up in share context menu). Sharing from Chrome shows ZERO issues...

It's Safari.... I'm also seeing inconsistent behavior sharing from Adobe to my app. The share is only successful 1/10 times or so, if you're lucky. In the share extension everything behaves per other use cases, and I store a path to the file (stored in shared app container) in user defaults. In the main AppDelegate, the userDefaults value only pulls non null 1/10 times. If I step through the share extension app, the userDefaults value is populated EVERY TIME in a debug session..

Zero issues on Android...

Sharing PDF file from Safari with Action Extension failing in Swift 4.2 Xcode 10
 
 
Q