How I like to code

Perforce and Xcode4

I created some AppleScripts that allow you to control some basic Perforce functionality in Xcode4, which was lost when Apple released the latest version of their IDE.

Perforce actually published a way of checking out files using the Behaviors functionality in Xcode (Xcode and P4), but I wanted a little more.

Note, these scripts are a work in progress. If you happen to make improvements, let me know so that those changes can be shared with the community.

You can download the AppleScripts here: xcode_p4_applescripts

Update
The AppleScript files are also being hosted on the public Perforce swarm forum, located here: Perforce Public Swarm Server

Update 2013-11-06
I updated the AppleScripts to work with Xcode5 only and added a couple of new scripts.

The new applescript files are referenced in post Perforce and Xcode5

10 Comments

  • Matt Attaway
    Posted 2013-08-14 at 4:23 pm | Permalink

    These are great! Any chance I can convince you to also publish them to the Perforce Public Depot? It’s going through some renovation work right now, but it’s our site for sharing tools with other Perforce users.

    http://swarm.public.perforce.com

  • Jaime
    Posted 2013-08-14 at 6:14 pm | Permalink

    Sure! I would love for the Apple development community, who are huge Perforce fans 🙂 of course, to have access to these AppleScripts.

  • Olivier Chatry
    Posted 2014-01-09 at 4:08 am | Permalink

    Hey !

    I will sound dumb, but how do you install these script ? How do you tell XCode to use them ?

    The whole applescript thing is kind of a mystery for me and I can seems to find any help with that :/

  • Jaime
    Posted 2014-01-11 at 2:14 pm | Permalink

    If you are not using AppleScript at all, chances are, you don’t see the AppleScript drop down menu.

    So, to use the AppleScripts, you have to make sure the menu is available. This option can be turned on within the AppleScript editor app, located at “/Applications/Utilities/AppleScript Editor.app”.

    After you open the AppleScript Editor.app, open the preferences and make sure the “Show script menu in menu bar” option is selected. After you turn on that option, you should see an AppleScript icon in your menu bar.

    Next, open Xcode and from the AppleScript drop down menu, select “Open Scripts Folder->Open Xcode Scripts Folder”, which should open a folder for you in the Finder; usually, the path is “~/Library/Scripts/Applications/Xcode”.

    Copy the AppleScripts I made for Perforce into that folder and when you go back into Xcode, you should see each of the AppleScripts there for your use.

    Any one of the AppleScripts can be opened in the AppleScript Editor so you can see how they work, which I would suspect you would do if you are having problems with the scripts working.

    Usually, when people ask me about scripts that aren’t working, it’s because they haven’t set up the p4 command line app or, and usually more often the case, they didn’t set up the P4HOST or P4CLIENT settings in the ~/.bash_login file.

    Let me know if you have any other issues and I’ll try to assist.

    Happy Coding!

  • Olivier Chatry
    Posted 2014-01-13 at 3:51 am | Permalink

    Thanks ! Yep I have been looking at the script :), but did not find out how to get them to work within XCode, thanks a bunch for the reply.

    The next question is : is their anyway to automate the checking out of the file, using your script, while editing a file ? Or do I have to use the batch script ? It seems I can’t get any applescript file to work with the “script” option of the “behavior” menu.

  • Jaime
    Posted 2014-01-14 at 1:51 pm | Permalink

    There is a way to do that, which Perforce listed on their website ( http://answers.perforce.com/articles/KB_Article/Automatically-Checking-Out-Files-for-Edit-in-Xcode/?q=checking+out+file+with+xcode+behavior&l=en_US&fs=Search&pn=1 ).

    Their solution uses the “File->Unlock” behavior in Xcode to automate checking out a file.

  • Olivier Chatry
    Posted 2014-01-15 at 2:11 am | Permalink

    Thanks for your answer, this is what I’m using know, but I wanted to use your script instead.

    No worry any way, everything is working OK.

    Thanks a lot to share this !

  • Jaime
    Posted 2014-01-15 at 9:43 am | Permalink

    Not a problem at all.

  • Jaime
    Posted 2014-01-15 at 9:46 am | Permalink

    You know, Matt Attaway over at Perforce wrote an article about how to work with your files without having to check them out first from Perforce.

    This is nifty trick for a lot of reasons, and if you think this may help you, check out the article over at http://www.perforce.com/blog/131112/say-goodbye-p4-edit

  • Rodney Allen
    Posted 2014-04-15 at 6:48 pm | Permalink

    Hi Jamie,

    I was told by perforce to use the scripts you developed.
    Can we talk about it in details?

    Thx in advance,

    regards
    Rodney Allen

2 Trackbacks

Post a Comment

Your email is kept private. Required fields are marked *