To be clear, the infrastructure that Apple has put in place for this is not documented for third-party use, so you’d have to rebuild that yourself.
If you wanted to do that, you’d have two problems to solve:
Networking — How does your software running on the Mac exchange data with your software running on the iPhone?
Security — How does your software running on the Mac actually unlock the Mac?
Overall, I would expect this to be quite challenging.
On the networking front, I suspect the way forward here is Bluetooth LE. That has a number of key advantages:
It’s very short range
On iOS, it offers flexibility with regards background execution
This last point is key: you need to be able to resume your iOS app in the background so it can exchange data with your Mac software, and there’s no general purpose support for doing that over Wi-fi.
If you have follow-up questions about Bluetooth LE, you can post them to Core OS > Bluetooth.
With regards the security side of this, that’s somewhat off topic for Core OS > Networking, but perfect for Core OS > Security.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"