The unity code prompts on Xcode: A build only device cannot be used to run this target.
If the phone is not connected, you will have the above prompt, you can use the emulator to fix it first.
Solution:
In Unity, you must click on Build Settings > Player Settings And in Inspector, choose settings for iOS > Other Settings > SDK Version and make sure “Simulator SDK” is selected.
Now in Xcode, it can be viewed in the iPhone Simulator.