views:

3064

answers:

6

Xcode 3.2 has removed the default templates for the scripting languages (Ruby, Python etc). How do I find these templates to use in Xcode 3.2? Would I need to add anything else to Xcode to support working with and 'building' PyObjC programs?

Additionally, is there any documentation and/or resources that would help me get into PyObjC (and Cocoa), taking into account I am already a Python guy?

+20  A: 

Apple now encourages people to get the templates directly from the PyObjC project. There's a nice thread of explanation archived on Cocoabuilder, with the following advice from bbum:

You'll need to download and install the templates from the PyObjC
repository or web site.

The templates were pulled from the release because the template
development moves at a different pace & schedule than the Xcode
releases. Too often, the templates have been out of date by the time
the discs were pressed.

The PyObjC website has both the templates for download, and great documentation/tutorials to get up and going.


Edit: Being a bit more specific, here's what I have done to get PyObjC working in Snow Leopard:

  • Using the Finder, I went to Go > Connect to Server... and connected to http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-xcode/ as a guest.

  • I then made a folder called Xcode on my local system at ~Library/Application Support/Developer/Shared/Xcode/. (You may already have this folder, but I hadn't customized anything for myself yet).

  • I copied the File Templates folder from the red-bean server into my new Xcode folder.

  • Copied the Project Templates folder to some other place, for example, the Desktop.

  • Using the Terminal, navigated to the temporary Project Templates folder on my Desktop and ran this command to "build" the template.:

$ cd ~/Desktop/Project\ Templates/

$ ./project-tool.py -k -v --template ~/Desktop/Project\ Templates/Cocoa-Python\ Application/CocoaApp.xcodeproj/TemplateInfo.plist Cocoa-Python\ Application ~/Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Cocoa-Python\ Application

  • Repeat for the other templates:

$./project-tool.py -k -v --template ~/Desktop/Project\ Templates/Cocoa-Python\ Document-based\ Application/CocoaDocApp.xcodeproj/TemplateInfo.plist Cocoa-Python\ Document-based\ Application/ ~/Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Cocoa-Python\ Document-based\ Application

$ ./project-tool.py -k -v --template ~/Desktop/Project\ Templates/Cocoa-Python\ Core\ Data\ Application/CocoaApp.xcodeproj/TemplateInfo.plist Cocoa-Python\ Core\ Data\ Application/ ~/Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Cocoa-Python\ Core\ Data\ Application

$ ./project-tool.py -k -v --template ~/Desktop/Project\ Templates/Cocoa-Python\ Core\ Data\ Document-based\ Application/CocoaDocApp.xcodeproj/TemplateInfo.plist Cocoa-Python\ Core\ Data\ Document-based\ Application/ ~/Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Cocoa-Python\ Core\ Data\ Document-based\ Application

  • I launched Xcode. The templates are now located under the "User Templates" section of the New Project... and New File... windows.

The default project built out of the box (no need to install anything else from the PyObjC project, or py2app). I cobbled up a silly program with one button and an action, and it worked beautifully, including integration with Interface Builder (I was able to control-drag to wire up actions and outlets).

I also recently stumbled across a series of "Getting Started" tutorials on a blog that seemed quite useful for beginners. The author appears to have put a lot of effort into the "Building Cocoa GUIs in Python with PyObjC" series (currently in 6 parts).

Jarret Hardie
Unfortunately, even after custom-installing the templates like mentioned above, you may run into troubles with XCode 3.2 and IB. For me, none of the RubyCocoa/PyObjC features that connect IB and XCode together are working – Apple seems to have dropped enthusiasm for these bridges only one release after advertising them.
arbales
I haven't had that experience, I'm afraid. IB is noticing new objects, and outlets and actions in those objects quite well.
Jarret Hardie
These instructions didn't work for me until I ran the Python script referenced in the README.
erikcw
Many thanks, erickw... while the instructions I originally posted did work, I didn't look closely enough at the target names and the application delegate name. I've amended my instructions to include the information in the README.
Jarret Hardie
After running the commands above, I had to go to the "Project Templates" folder, create the "Cocoa-Python" folder and move the 4 template folders into the new one. Only after that the templates appeared in Xcode. I suppose, Xcode wants a compulsory "template group" folder. I reckon the commands above could be amended to include this change.
vit
+1  A: 

I downloaded the helpful zip file of PyObjC Xcode templates provided by a fellow PyObjC user on the PyObjC-dev mailing list:

http://tr.im/za8a

(link was heinously long, hence tr.im-ing it; scroll down past the calendar for the good stuff)

It's been working fine for me so far.

One Crayon
+1  A: 

Check out this blog posting... fixed it perfectly for me: http://ioanna.me/2009/09/installing-pyobjc-xcode-templates-in-snow-leopard/

Cory
A: 

This is just a zip file that "One Crayon" pointed to, it is indeed helpful, just download this file unzip it & then paste the entire folder here:

~/Developer/Library/Xcode/Project\ Templates

The file:

http://bit.ly/150NUx

Good Luck people & thanks!

A: 

The link that Cory posted works like a charm! Thanks to everyone for your help though! PYTHON FTW! :-D

Q DUB
A: 

Thanks for the post -- I, too, lost my pyobjc templates on the latest upgrade.

A while back, I wrote up some details ( here ) on crossing the pyobjc both ways. It's proved helpful to a few developers, especially if you want to use ObjC for the GUI stuff and Python for the lifting (and therefore need the pybojc bridge to work both ways).

Red Byer