It is also useful to note that in the settings / behavior there is a setting for adding behavior to certain actions. One of them is the Unlock File, which can be associated with a shell script, as here:
#!/bin/sh RESULT=`/opt/local/bin/p4 edit ${1#file://localhost} 2>&1` SHRESULT=$? while [ $SHRESULT -ne 0 ] do SCRIPT="tell application \"XCode\" to display dialog \"$RESULT\" buttons {\"Try again\",\"Cancel\"} default button 1" osascript -e "$SCRIPT" if [ $? -ne 0 ] then break fi RESULT=`/opt/local/bin/p4 edit ${1#file://localhost} 2>&1` SHRESULT=$? done exit $SHRESULT
To invoke p4 edit when the editor should start making changes.
This update has been updated to install a dialog box if the p4 file does not work. This will try again if you click "Try Again" and stop when you click "Cancel", which is especially useful if you happen to have your username expiring in the first case or not connected to your server in second place.
Unfortunately, it seems that the exit code has not been verified to verify that the unlock was successful, and it looks like Xcode is changing the file to r / w in this case, so be careful when you get an error message that you either get editing to succeed, or edit the file later.
Obviously this solves the problem of unlocking / editing files, but I find that I like to use p4v for sending anyway.
Multiple Customers / Workspaces
For those of you who can use multiple clients on the same machine (something we do more now, when we use streams with Perforce more often), it can be difficult to make sure that the correct client is used to work on the file you are editing .
For us, we found the easiest fix that uses P4CONFIG to denote a specific perforce configuration file. In our case, we usually use .p4config-<user/host> , so I can have .p4config-laptop-gaige and choose or check it, if necessary, not interfere with .p4config-desktop-gaige . Inside the .p4config file .p4config we install P4CLIENT , and this ensures that the p4 command knows which stream to use.