1 Reply
      Latest reply on Jul 24, 2019 12:38 PM by matamatangi
      matamatangi Level 1 Level 1 (0 points)

        I have a macOS app with a helper tool that communicates via an XPC connection. In 10.15 Beta 4, a document-based security scoped bookmark fails when it is passed from the main macOS app to the helper app.



        In the sample code below from the main app, a bookmark is created from a URL and the attribute is saved on “/Users/tperfitt/passing”:



            NSURL *wimURL=[NSURL fileURLWithPath:@"/Users/tperfitt/Desktop/test.winclone/Windows.wim"];

            NSError *error;

            NSData *bookmark = [wimURL bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope


                                                    relativeToURL:[NSURL fileURLWithPath:@"/Users/tperfitt/passing"]





        If I resolve this in the main app, it resolves fine. However, if I pass the NSData to the helper app over an XPC connection and attempt to resolve it, it resolves as nil and error is set. The system log shows:



        2019-07-23 18:02:03.577313-0500  localhost com.twocanoes.WincloneHelper[3026]: (CoreServicesInternal) the ScopedBookmarkAgent service could not be found (configuration error)



        I verified that the NSData is being passed from the main app to the helper app:



            NSURL *url = [NSURL URLByResolvingBookmarkData:data


                                             relativeToURL:[NSURL fileURLWithPath:@"/Users/tperfitt/passing"]





        This returns nil and the error is set as :



        Error Domain=NSCocoaErrorDomain Code=256 "ScopedBookmarksAgent did not return error domain during resolution" UserInfo={NSDebugDescription=ScopedBookmarksAgent did not return error domain during resolution}



        The file has an xattr on it:



        root@MacBook-Pro ~ # xattr passing                   




        I expected that the helper tool could resolve the URL and have access to the file. Instead, it returned nil.