Skip to content

Instantly share code, notes, and snippets.

@jstgermain
Last active January 16, 2024 15:33
Show Gist options
  • Save jstgermain/10c928fb07a4d2edb70ecddc654d5356 to your computer and use it in GitHub Desktop.
Save jstgermain/10c928fb07a4d2edb70ecddc654d5356 to your computer and use it in GitHub Desktop.
xcode-fix-connection.sh
#!/bin/bash
# Script to disable the iOS Simulator app from showing the "Do you want the application xxxx to accept incoming network connections?" pop-up every time the app is run
echo "> Enter password to temporarily shut firewall off"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
echo "> Add Xcode as a firewall exception"
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/MacOS/Xcode
echo "> Add iOS Simulator as a firewall exception"
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator
echo "> Re-enable firewall"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
exit 0
@jstgermain
Copy link
Author

When running this script, you may need to chmod the file first. Save the file to your system under ~/xcode-fix-connection.sh.

In terminal, run:

chmod u+x ~/xcode-fix-connection.sh

After that is complete, you should be able to run:

~/xcode-fix-connection.sh

You will enter your password, and then you should see output similar to this.

Firewall is disabled. (State = 0)
> Add Xcode as a firewall exception
Application at path ( /Applications/Xcode.app/Contents/MacOS/Xcode ) added to firewall 
> Add iOS Simulator as a firewall exception
Application at path ( /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator ) added to firewall 
> Re-enable firewall
Firewall is enabled. (State = 1) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment