First, we need to create a script with the following body:

It opens either .xcodeproj or .xcworkspace.

After that don’t forget to make this script as an executable by the special command: chmod +x <your_script.sh> (you can check more about this command here) and save it to some directory wherever you want (in my case it’s a user directory).

If you prefer iTerm, just change the Terminal keyword to iTerm in this script.

The next one is creating a custom Xcode’s behavior. Open Xcode and follow the next steps: Xcode menu > Behaviors > Edit Behaviors… Then at the bottom of the popup appeared press the + button.