When you move close to an object (note: not only when zooming, but as well when just moving the phone closer), it switches to the ultra.wide camera.
I know that I can enable automatic switching by using .builtInTripleCamera. However, it does not switch automatically just because I move the camera closer to an object. I think that is the magic behind the "macro mode".
I did not find anything in the docs - how can I enable the macro mode in my own camera app?
Apple say "When the video zoom factor increases and crosses a camera’s switch-over zoom factor, this camera becomes eligible to set as the activePrimaryConstituentDevice." in this document: https://developer.apple.com/documentation/avfoundation/avcaptureprimaryconstituentdevicerestrictedswitchingbehaviorconditions
So if you want your app can switch to ultra.wide camera when move iPhone close and switch to Angle Camera when fay away, you need set you device.videoZoomFactor = device.virtualDeviceSwitchOverVideoZoomFactors.first. For iPhone 14 Pro, the value is 2.
If you write like this, you can find you App can switch camera like iPhone Native Camera App.