2 Replies
      Latest reply on Jan 10, 2017 11:19 AM by TRL
      TRL Level 1 Level 1 (0 points)

        I want to use my mac to set up a WiFi, then connect my iPhone to that WiFi so that they can share data/message through local WiFi. Then there is an app written by Swift 3 running on iPhone which will send and receiver data to/from a python script running on Mac. How to do this?


        For example, there is a slider in the Swift app, then when I drag the slider change the value, then the value will be sent to Mac and data will be printed out real time.


        This is really important to me as a very small part of my project.


        Anyone can give some help?



        • Re: Data exchange between iPhone and Mac
          eskimo Apple Staff Apple Staff (13,925 points)

          A lot of the back story here is covered by Technote 2152 Document Transfer Strategies.  I suggest you give it a read.

          Note TN2152 hasn’t been updated in a while but that’s probably OK in this case because your requirements put you in a space that hasn’t changed much since its last update.

          If were in your shoes I’d do the following:

          • On the server, NSNetService to advertise its presence.

          • On the client, use NSNetService to find the server.

          • Use HTTP as the protocol.  This is well supported on the client (via NSURLSession) and it’s easy to implement the server side using Python.

          The major gotcha here is security.  The fundamental building block here is HTTP (that is, HTTP over TLS) but putting them together for a peer-to-peer app is quite tricky.

          Share and Enjoy

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