4 Replies
      Latest reply on Jul 2, 2019 5:59 AM by tantares
      tantares Level 1 Level 1 (0 points)

        Hello,

         

        My goal is to extract names from OSX Contacts. Following the hints, I try to use the CNContactStore. I'm working with Xcode 10.1 and Swift.

         

        Unfortunatley I found no way of exploring code in a Xcode Playlist, since there is no info.plist created and hence I can't enter the required privilege key, which is required for accessing the ContactStore. Does anyone know how to get privilege access in Playlist codes?

         

        When I try the code in a "Command Line Tool", I face the same problem. However when I create a running exec, it does work. Trying the same code in a Cocoa App using the priv key in info.plist, results in the following error:

         

        2019-05-13 23:54:10.586962+0200 Show Clients[2324:83437] [default] Unable to load Info.plist exceptions (eGPUOverrides) CNAuthorizationStatus

        2019-05-13 23:54:30.347100+0200 Show Clients[2324:83437] Could not get real path for Address Book lock folder: open() for F_GETPATH failed.

        2019-05-13 23:54:30.347101+0200 Show Clients[2324:83437] Unable to open file lock: {recursion count = 0, name = nil}, fileDescriptor=-1> Error Domain=NSPOSIXErrorDomain Code=14 "Bad address" UserInfo={ABFileDescriptor=-1}

         

        So I'm really stuck and would appreciate any help

        Tony

        • Re: Xcode playlist privileged access to Contacts
          eskimo Apple Staff Apple Staff (11,845 points)

          Unfortunately I found no way of exploring code in a Xcode Playlist …

          Just to confirm, you’re talking about Xcode playgrounds, right?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: Xcode playlist privileged access to Contacts
              tantares Level 1 Level 1 (0 points)

              Yes, I'm using Xcode playlist

                • Re: Xcode playlist privileged access to Contacts
                  eskimo Apple Staff Apple Staff (11,845 points)

                  I wrote:

                  you’re talking about Xcode playgrounds, right?

                  You wrote:

                  Yes, I'm using Xcode playlist

                  Wha?

                  Still, I’m going to assume that the “Yes” is correct and the “playlist” is wrong and move on.


                  I think your initial analysis is correct.  There’s no way to add the contacts usage string to a playground, and thus there’s no way to use Contact framework from the playground.

                  When I try the code in a "Command Line Tool", I face the same problem

                  Correct.  However, you should be able to achieve a similar result by creating an app project, setting it up to access contacts, and then running the app’s main executable from Terminal.

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"