Re: iOS open In place, permission denied

2020-04-28 Thread Markus Spoettl via Cocoa-dev

On 4/28/20 11:23 AM, Markus Spoettl via Cocoa-dev wrote:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url 
options:(NSDictionary *)options


Just in case anyone is interested, main part of the solution is to wrap the usage of url 
inside a


[url startAccessingSecurityScopedResource];

[url stopAccessingSecurityScopedResource];

sequence (plus use a NSFileCoordinator to read the file's contents, but that's really 
secondary).


This was surprisingly difficult to figure out, the documentation really sucks.

Markus

--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


iOS open In place, permission denied

2020-04-28 Thread Markus Spoettl via Cocoa-dev

Hi everyone,

  I have a strange problem with the

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url 
options:(NSDictionary *)options


app delegate method, that seems to have cropped up a couple of weeks ago when switching to 
the iOS 13 SDK (from 12). My app can no longer access files that are sent to it via "Open In".


My app declares the relevant UTIs and sets

UIFileSharingEnabled
LSSupportsOpeningDocumentsInPlace

in the Info.pList. The App delegate receives the message above just fine, but accessing 
the given URL yields the following error (when using "Open In" from the Files.app):


Error Domain=NSCocoaErrorDomain Code=257 "The file “foo.bar couldn’t be opened because you 
don’t have permission to view it." 
UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/372CF62C-2C92-446A-9A7E-0CA3884388A2/File 
Provider Storage/foo.bar, NSUnderlyingError=0x281ce7120 {Error Domain=NSPOSIXErrorDomain 
Code=1 "Operation not permitted"}}


I've tried copying the file (it is a local file) via NSFileManager -copyItemAtURL::: as 
well reading its contents via NSData -dataWithContentsOfURL::: both produce this 
permission error.


This worked fine prior to switching to Xcode 11 and the iOS SDK 13, I'm sure I'm just 
missing a tiny bit that is now required.


Thanks for any pointers!

Best Regards
Markus

--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com