February 26, 2005

Apple == Python, Perforce, XCode - Pure Nirvana

Ok I figured out how to get XCode to build a decent coding environment for python. This includes getting the SCM (Perforce) integrated and building a (quasi) debugging environment using pdb.py. If this interests you then follow along.

In this piece I will detail how to get perforce and XCode to play nicely.

Step 1 - Getting a SCM setup that works for you.

Ok I figured out how to get perforce to work on my linux box. And now I have a place to play. How do I want the directory structure to fit is a common question. So let me outline how I think I want my development environment setup. I've bee a long time hacker, and this is the first time I want to enable perforce SCM for all of my development (perhaps others) activities. So how do I want this setup? When I am finished I want a directory structure that looks like this:
<some base directory>

scripts

perl
python
.
.

projects

proj1 (Some XCode or other project)
proj2
.
.
projN

So this seems simple enough - and it is. After a bit of trial and error playing with P4CLIENTS I have this setup. So let's assume you have a server (called server).

Ensure you have an empty base directory. For this example I created a directory on my client ( mkdir ~/depot ). Next create a client workspace. I used p4v to do this and simply did the following:

  • Open Connection (File->Open Connection)
  • Connect To: < your server and port >
  • Connect As: < your username > ( if this is the first time you must select New.. )
  • Client Workspace:
  • I named one steven and selected New..
  • Under the name I called it steven
  • Owner: Steven
  • Host: <default>
  • Description: Steven depot
  • Root: <base directory>

Now you should have a empty directory tree. Let's add our appropriate directories.

mkdir ~/depot/scripts/python
mkdir ~/depot/projects

Ok now let's put a file in the python directory and use p4v to check the thing in.

cp <my python script> ~/depot/scripts/python

Ok switch over to the p4v and refresh the Client Workspace. Seeing your new file right click and "open for add", then right click "submit"

Cool it should work. Now let's get xcode to play nicely..

Step 2 - Create a XCode project for python

This is very basic - fire up XCode ( get it from here ) and create a new empty project.

  • The type is an Empty Project
  • Give is a <project name>
  • The directory needs to be <base directory>/projects/<project name> ( ~/depot/projects/PythonTest1 )

And that's it. Now let's add SCM - version control..

Step 3 - Getting Perforce to play nicely.

One of the things I despise is when documentation points you to a particular place and no amount of searching seems to dig up the answer. So you dig and dig and finally piece together the appropriate answer. Such is the documentation for getting XCode to play with Perforce. Assuming you're an XCode junkie the docs are straightforward enough. For this part time player - I was unnerved by the following statement that was stated in the docs under the section of Perforce.

"Open the project in Xcode and set the SCM system to Perforce. See Xcode Help for details."

So what the hell does this mean? Perhaps preferences? No. Perhaps it's per project - don't know. Time for google (like life in general) - After a big of digging I find out. I need to see an inspector.. This can be found by either right clicking under the top most group and saying get info or under File->Show Inspector.

Once this is up all you need to do is under the General Tab at the bottom enable SCM. and edit the appropriate options.

  • perforce tool path (/usr/local/bin/p4)
  • P4PORT ( hostname:port )
  • P4CLIENT ( from above - I called my steven )
  • Username and Password ( from above )

At this point you should have a perforce enabled environment.

Posted by Steven at February 26, 2005 03:21 AM
Comments
Post a comment









Remember personal info?




You must enter the security code to post!