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/xxx/Library/Developer/CoreSimulator/Devices/FE5463C2-FAA3-
41A9938B-C1C234EA966A/data"/Containers/Data/Application/B6FB42C6-B4E3-
46D8-B9F95856FF88F0B6/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:
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>
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
</string>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.ui-services</string>
</dict>
The solutions works for me is iOS has stopped this kind of support in iOS12 so what i did to fix this issue. Earlier i was using this completion handler for this method loadItemForTypeIdentifier
completionHandler:^(id <NSSecureCoding> urlItem, NSError *error)The type information for the first parameter of your completionHandler block should be set to the class of the expected type. For example, when requesting text data, you might set the type of the first parameter to NSString or NSAttributedString. An item provider can perform simple type conversions of the data to the class you specify, such as from NSURL to NSData or NSFileWrapper, or from NSData to UIImage (in iOS) or NSImage (in macOS). If the data could not be retrieved or coerced to the specified class, an error is passed to the completion block’s.
Call this like this