Perforce Checkout Macro for Xcode4

I would like to configure a macro in Xcode 4 to check the current file from Perforce. How can i do this? I have no interaction with my project, and I do not want to do this. This is pretty easy in Visual Studio, but I don't know the Xcode equivalent.

+6
source share
4 answers

The closest I can think of is a service, so it looks like Xcode 4 Perforce Services can do the job. However, I have not tried this personally. I came across him in on this question .

+1
source

Just stumbled upon this on Perforce.com as a means to get the job done. I tried it and it is very good.

http://answers.perforce.com/articles/KB/2997

According to the comment, it also works in Xcode 5.

And now it is tested and works in Xcode 6!

EDIT: If that doesn't work and you use OS X Mavericks, this guy fixed the script to keep working. Just make sure the script references p4 correctly. 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

+4
source
  • Make sure the command line tool 'p4' is set to '/ usr / local / bin /'.
  • Verify that the Perforce environment variables are configured correctly. I use the perforce.rc file in the root of each client workspace with the client name (P4CLIENT) and port (P4PORT). Do not forget about P4USER, P4PASSWD, P4CONFIG, etc.
  • Create the following script in your ~ / bin folder and make sure that the permissions are set so that they are executed (755 should work).
  • Go to the settings in Xcode and select "behavior".
  • Scroll down to the "Unlock file" section.
  • Scroll down again and check the box next to "Run."
  • Select "Select Script ..." and point it to the following script:

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 properly configured, unlocking the file in Xcode should run this script and try to verify the file. Unfortunately, any output goes to '/var/log/system.log'. I am not sure how to notify Xcode 4 of an error in this Script.

+2
source

This is crazy trying to get Xcode to work with Perforce. Here is the solution I came up with:

  • Quick setup
  • Muscles are easy to write, so you don’t need to think to check files.
  • Requires no mouse at all

One-time setup:

  • Download and install the free DTerm app from Decimus Software.
  • Make sure you have the Perforce command-line tool installed. Type "p4" at the terminal command line and see if it recognizes this command. If not, you need to go to the Perforce website and find and download what they currently call the "Perforce (P4) command line client." There is no installer; just save it from your browser directly to /usr/bin (or something else) and do chmod + x on it. For official customization notifications, and if you need to do any custom environmental tricks, see this tech note .

Once you do this, say you are in Xcode and you are viewing the source code file that you want to verify. Here's rigamarole:

  • Display the file in the active Xcode editor
  • Press Shift Command Enter to get the DTerm window
  • Type p4 edit , and then press Shift Command V to insert the file name of the active file, and press return
  • Perforce checks the file and DTerm shows you status / errors.
  • Click Escape to close the DTerm window.
  • Start making changes to the file in Xcode. Xcode can (erroneously) say that the file is read-only, because it is dumb and does not know that it is made from read-only read-write, so you need to click Allow editing. At first I did not trust this and twice tested it several times, but now I have a blind faith that he is doing the right thing.

I did not ask this after a while, so please let me know if you encounter any glitches, and I will update the information here to make it as painless as possible. But otherwise, this is the best solution I have found.

+1
source

All Articles