7 Replies
      Latest reply on May 5, 2020 12:11 PM by joconnor
      willwhite Level 1 Level 1 (0 points)

        I'm sorry if this isn't in the right place in the forums.

         

        How could my macOS application expose an API for other macOS applications to use? I want other applications to be able to send data to my application, and my application will take care of storing that data. During development, I also want to be able to manually interact with my application via its API, eg by typing in commands.

        • Re: Application exposing an API
          jonprescott Level 3 Level 3 (100 points)

          What you are describing seems to fit the description of a Launch Agent, or Launch Daemon.  There are guides in the Apple documentation on how to build a launch agent or launch daemon.  Launch agents can even have a GUI (I think).  Nice thing about agents and daemons is that can be started up by the system on demand, you don't have to start it manually.

          • Re: Application exposing an API
            eskimo Apple Staff Apple Staff (13,885 points)

            How could my macOS application expose an API for other macOS applications to use?

            Are you targeting the Mac App Store?  Or distributing independently using Developer ID?

            Share and Enjoy

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

              • Re: Application exposing an API
                willwhite Level 1 Level 1 (0 points)

                I'm targeting the Mac App Store.

                  • Re: Application exposing an API
                    eskimo Apple Staff Apple Staff (13,885 points)

                    I'm targeting the Mac App Store.

                    That makes things tricky.  In general, Mac App Store apps are not allowed to make changes to the system as a whole, which rules out all the launchd options.

                    I can see two feasible here:

                    • Apple events — If you make your app scriptable, other apps can request that you do work by sending you Apple events.

                    • TCP/IP — Mac App Store apps are allowed to opening listening sockets, assuming you apply the com.apple.security.network.server entitlement.  There’s a couple of gotchas here.  The obvious one is security: You don’t want your app accepting requests from across the network.  The less obvious one is App Review.  My experience is that they look carefully at apps with the com.apple.security.network.server to ensure that they provide some obvious user-level server feature.

                    If I were in your shoes, I’d do the Apple events thing.

                    Share and Enjoy

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

                • Re: Application exposing an API
                  joconnor Level 1 Level 1 (10 points)

                  Have you looked into an AppleScript dictionary?