Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode4 doesn't support Perforce?

xcode4 doesn't support Perforce?

I add a repository in xcode4. Only subversion and Git to choose.

how to add a perforce repository?

thank you.

like image 596
Yu-Sen Han Avatar asked Mar 14 '11 07:03

Yu-Sen Han


4 Answers

It's also useful to note that there is a setting in Preferences/Behaviors to add behaviors to particular actions. One of those is Unlock File, which can be bound to a shell script, like the one 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

In order to invoke p4 edit when the editor needs to start making a change.

This has been updated to put up a dialog box if the p4 edit fails. This will repeatedly attempt it if you hit "Try Again" and will stop when you hit "Cancel", which is particularly useful if you happen to have your login expire in the first case or aren't connected to your server in the second place.

Unfortunately, it appears that the exit code isn't checked to make sure that the unlock succeeded, and it appears that Xcode changes the file to r/w in this case, so be careful when you get an error message that you either get the edit to succeed or edit the file later.

Obviously, that only solves the problem of unlocking/editing files, but I find that I like to use p4v to submit anyway.

Multiple clients/workspaces

For those of you who might be using multiple clients on the same machine (something we're doing more of now that we use Streams more often with Perforce), it can be challenging to make sure that the correct client is used to work on the file you are editing.

For us, we found the easiest fix to be using P4CONFIG to denote a specific perforce configuration file. In our case, we generally use .p4config-<user/host>, this way I can have .p4config-laptop-gaige and choose to either check it in if need be without interfering with the .p4config-desktop-gaige. Inside of the .p4config file, we set P4CLIENT, and that makes sure that the p4 command knows which stream to use.

like image 93
gaige Avatar answered Nov 12 '22 19:11

gaige


I threw together a couple of Automator services that let you bind hotkeys for p4 edit/p4 add on the currently open file in Xcode 4. It's not ideal, but it beats switching to terminal or p4v.

https://github.com/jcohen/xcode4-perforce-services

like image 33
Joshua Cohen Avatar answered Nov 12 '22 20:11

Joshua Cohen


Support for perforce was officially dropped from Xcode 4. Unless they add it back in, you'll have to figure something else out.

like image 3
jakev Avatar answered Nov 12 '22 21:11

jakev


The technique I mentioned in this question works for Perforce as well. In fact, this was my original use for DTerm.

Since Perforce support was severely broken in Xcode 3.0 I have been using DTerm for checking out files and getting their status for several years.

like image 1
Mark Avatar answered Nov 12 '22 20:11

Mark