It depends on the spy app. Some require the device to be jailbroken, while others don’t. Some of the best no-jailbreak iPhone apps instead use the iCloud credentials of the target device and sync the data through this, so they don’t require jailbreaking the device. However, you will typically need access to the target iPhone to verify the two-factor authentication code sent to it.