macOS firewall - allow iOS apps running in the simulator
macOS has an awesome firewall, however the default setting is very harsh for us iOS developers.
When debugging iOS apps requiring incoming network connections to function in the simulator, this popup appears:
Pressing Allow gets old real fast.
Here is how you can disable the popup for all your iOS apps. In the Terminal, execute the following commands.
#temporarily shut firewall off:
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
#put Xcode as an exception:
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/MacOS/Xcode
#put iOS Simulator as an exception:
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator
#re-enable firewall:
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
The lines with hashtags (#) are Bash comments and can be omitted, but these are useful if you use the commands i a script.