URL extension item has inconsistent file permissions across different container apps

Originator:abarinov
Number:rdar://18069472 Date Originated:8/19/2014
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 8 Beta 5
Classification: Reproducible:
 
Summary:
When I load extension items as NSURLs (as opposed NSData, UIImage, etc) like so:
 
[itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypePDF options:nil completionHandler:^(NSURL *fileURL, NSError *error) {
 
I have noticed inconsistent behavior with respect to to file permissions. For example, the assertion
 
NSAssert([[NSFileManager defaultManager] fileExistsAtPath:fileURL.path], @"fileURL must point to a path which exists");
   
will fail in some apps and not in others when an extension accepts PDF documents.

Steps to Reproduce:
Create an app extension that accepts documents, load extension items as URLs and evaluate this assertion for each URL:

NSAssert([[NSFileManager defaultManager] fileExistsAtPath:fileURL.path], @"fileURL must point to a path which exists");

Run the extension within the latest Box app.

Share a PDF document with extension.

The assertion will fail.

Running the same extension in Mail or Safari will not trigger assertion failure.

Expected Results:
Expect the assertion to consistently pass.

Actual Results:
The assertion sometimes passes and sometimes fails for certain apps, such as Box.

Version:
iOS 8 Beta 5

Notes:


Configuration:
iPad 3

Comments

AirXmail: the problem isn't my extension being able to access the URL, it's the NSURLSessionUploadTask being able to access it in its own process.

Have you tried using -startAccessingSecurityScopedResource?


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!