I'd like to setup a macro in XCode 4 to checkout the current file from Perforce. How can I do this? I do not have perforce integrated with my project and do not wish to do so. This is pretty easy in Visual Studio but I don't know the XCode equivalent.
Just came across this at Perforce.com as their means of making this work. I tried it, and it's pretty good.
http://answers.perforce.com/articles/KB/2997
As per the comment, it works in Xcode 5 as well.
And now it's tested and working in Xcode 6!
EDIT:
If that doesn't work, and you're using OS X Mavericks, this guy fixed the script to keep working. Just make sure the script references p4 properly. I had to change it from /usr/local/bin/p4
to /usr/bin/p4
.
http://forums.perforce.com/index.php?/topic/2830-xcode-501-x-mavericks-perforce-integration-not-working/#entry11319
xcodeunlock.sh
#!/bin/bash
# Xcode4 doesn't setup the environment
source ~/.bashrc
# Delete the URL part from the file passed in
fn=${BASH_ARGV#file://localhost}
echo "fn=" $fn
if [ -a ${fn} ]; then
res=$(/usr/local/bin/p4 edit ${fn})
# TODO: Report the status back to the user in Xcode
# This output goes to the console.
echo $res
else
echo "FnF" ${fn}
fi
Once this is set up correctly, unlocking a file in Xcode should run this script and attempt to checkout the file. Unfortunately any output goes to '/var/log/system.log'. I'm not sure how to notify Xcode 4 of a failure in this script.
It's maddening trying to get XCode to work with Perforce. Here is a solution I came up with that is:
One-time setup as follows:
/usr/bin
(or whatever) and do a chmod +x on it. For official setup notes, and if you need to do any custom environmental variable tricks, please see this tech note.Once you've done this, let's say you are in XCode and you are viewing a source code file that you want to check out. Here's the rigamarole:
Shift Command Enter
to get a DTerm windowp4 edit
and then hit Shift Command V
to paste in the filename of the active file, and hit returnI haven't set this up in a while, so please let me know if you run into any glitches and I'll update my info here to make it as painless as possible. But otherwise, this is the best solution I've found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With