I am now thinking that the issue is not with socketfilterfw, but with the encoding of the path. I noticed on Catalina that Xcode will add your app to the firewall, if you open a socket and are listening to it. So I moved my simple socket server over to Beta 11.1 and ran it. At first, nothing happened, but after setting the global state on, the app appeared. As you will see, there is now a valid path being displayed in socketfilterfw, but when I try to remove it, I get the same error "The file path you specified is invalid". Here is my terminal session:
vagrant@Vagrants-Mac ~ % sudo /usr/libexec/ApplicationFirewall/socketfilterfw --listapps
vagrant@Vagrants-Mac ~ % sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
Firewall is enabled. (State = 1)
vagrant@Vagrants-Mac ~ % sudo /usr/libexec/ApplicationFirewall/socketfilterfw --listapps
ALF: total number of apps = 1
1 : /Users/vagrant/Library/Developer/Xcode/DerivedData/SocketServer-ftagnsjglzldkpdpxewhonpchqay/Build/Products/Debug/SocketServer.app
( Allow incoming connections )
vagrant@Vagrants-Mac ~ % sudo /usr/libexec/ApplicationFirewall/socketfilterfw --remove /Users/vagrant/Library/Developer/Xcode/DerivedData/SocketServer-ftagnsjglzldkpdpxewhonpchqay/Build/Products/Debug/SocketServer.app
The file path you specified is invalid
vagrant@Vagrants-Mac ~ % locale
LANG="enUS.UTF-8"
LCCOLLATE="enUS.UTF-8"
LCCTYPE="enUS.UTF-8"
LCMESSAGES="enUS.UTF-8"
LCMONETARY="enUS.UTF-8"
LCNUMERIC="enUS.UTF-8"
LCTIME="enUS.UTF-8"
LCALL=
vagrant@Vagrants-Mac ~ % sw_vers
ProductName: macOS
ProductVersion: 11.1
BuildVersion: 20C5048k
vagrant@Vagrants-Mac ~ %