NSSharing Issues

are there any entitlements required to use NSSharing?

NSUUID* uuid = [NSUUID new];
NSString* tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:[uuid UUIDString]];
NSFileManager* fm = [NSFileManager new];
[fm createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:nil];
NSString* tempFile = [tempDir stringByAppendingPathComponent:pdfFileName];
NSURL* fileURL = [NSURL fileURLWithPath:tempFile];
NSData *data = [self.mainPlainTextView dataWithPDFInsideRect:[self.mainPlainTextView bounds]];
PDFDocument *pdfDoc =[[PDFDocument alloc] initWithData:data];
[pdfDoc writeToURL:fileURL];
self.shareStdItemsArray= @[fileURL,self.sharedString];
NSSharingServicePicker * picker = [[NSSharingServicePicker alloc] initWithItems:self.shareStdItemsArray];
picker.delegate = self;
[picker showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];


2017-01-04 22:40:24.349028 macEnact[16037:4771223] --error: [ShareKit] SHKSandbox: No read access to file file:/

2017-01-04 22:40:30.937291 macEnact[16037:4771223] warning: illegal subclass SHKRemoteView instantiating; client should use only NSRemoteView (


What am I doing wrong?


macOS10.12.2 xc 8.2.1

Replies

Did you ever resolve this? I get this too on macOS 10.13 High Sierra.


Although I'm not getting the read access error, I am getting the warning illegal subclass SHKRemoveView error.

Hi. Did you ever find a fix for this? I'm also seeing it along with a weird display of the sharing panel.


macOS 10.13.3

Hi


I had the similar issue and I solved it with very simple method. the file ur was showing in log like this:


file:///Users/mediajon/Desktop/try/Creative%20Convert.svg


that's why it showed no read file access. I removed strings from the beginning and the result is:


/Users/mediajon/Desktop/try/Creative%20Convert.svg


after that, the problem has gone and sharing function is working normal.

still getting this error. XC 9.4.1. HighSierra 10.13.5 The share item in this case is a simple attributed string, no url involved...

2018-07-06 16:34:04.212976-0700 Enact[10816:4068677] warning: illegal subclass SHKRemoteView instantiating; client should use only NSRemoteView (
  0   ViewBridge                          0x00007fff541bebff -[NSRemoteView _preSuperInit] + 195
  1   ViewBridge                          0x00007fff541bef83 -[NSRemoteView initWithFrame:] + 25
  2   ShareKit                            0x00007fff504a0aa5 -[SHKRemoteView initWithOptionsDictionary:] + 161
  3   ShareKit                            0x00007fff5047ffbd __38-[SHKSharingService performWithItems:]_block_invoke_4 + 1347
  4   libdispatch.dylib                   0x0000000100710cae _dispatch_call_block_and_release + 12
  5   libdispatch.dylib                   0x0000000100708d8f _dispatch_client_callout + 8
  6   libdispatch.dylib                   0x0000000100714e09 _dispatch_main_queue_callback_4CF + 549
  7   CoreFoundation                      0x00007fff2f764c69 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
  8   CoreFoundation                      0x00007fff2f726e4a __CFRunLoopRun + 2586
  9   CoreFoundation                      0x00007fff2f7261a3 CFRunLoopRunSpecific + 483
  10  HIToolbox                           0x00007fff2ea0cd96 RunCurrentEventLoopInMode + 286
  11  HIToolbox                           0x00007fff2ea0cb06 ReceiveNextEventCommon + 613
  12  HIToolbox                           0x00007fff2ea0c884 _BlockUntilNextEventMatchingListInModeWithFilter + 64
  13  AppKit                              0x00007fff2ccbea73 _DPSNextEvent + 2085
  14  AppKit                              0x00007fff2d454e34 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
  15  AppKit                              0x00007fff2ccb3885 -[NSApplication run] + 764
  16  AppKit                              0x00007fff2cc82a72 NSApplicationMain + 804
  17  Enact                               0x00000001001cd925 EnactApplicationMain + 5365
  18  Enact                               0x00000001001cfcb6 main + 358
  19  libdyld.dylib                       0x00007fff57534015 start + 1