Ever wondered what it would be like to run HTTP servers at the edge, but the HTTP servers were mobile apps themselves? Also, they could talk to each other even without an internet connection.
This project shows off how you can turn mobile apps like an iPhone on the local area network into a server. This concept broadly introduces how developers can think of mobile devices as more than mere client devices, but also as intelligent, cloud-optional servers. For more information on a more out-of-the box solution see the Ditto Platform
- Make sure your devices are on the same Local Area Network.
- Ensure that your Local Area Network does not have Client Isolation Mode turned on. Client isolation ON means that peer to peer discovery on the Local Area Network is not possible.
- Open up ios/MobileMicroservices.xcproj
- Swift Package Manager will begin downloading Vapor
- Run the app ideally on an iPhone or iPad. You can run it in the simulator, but only 1 at a time.
- The HTTP Server is a Swift framework called Vapor
- Service Discovery is handled via Apple's Network Framework's
NWBrowser
. - Note,
NWBrowser
does not have the ability to resolve a Hostname.NetServiceBrowser
does but has been labeled as deprecated as of iOS 15. - This project is a proof of concept and isn't recommended without a more robust implementation. Host name resolution depends more on Apple's device name guidelines described here.
- SwiftUI preview simulators will not start the
NWBrowser
services.
Coming Soon!