PyObjC development with Xcode 3.2
Asked Answered
F

3

16

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?

Folks answered 12/9, 2009 at 9:27 Comment(1)
I'm a python guy too, and I've been learning Cocoa. I don't think you'll find a better way to get into PyObjC then to ignore Python the time to learn Cocoa and Objective-C then come back to Python and PyObjC after you understand it. Unfortunately, Cocoa is a very un-pythonic framework, and there isn't much in the way of dedicated PyObjC education materials. If you learn Cocoa/ObjC first, you'll be so happy to get back to Python afterwards and PyObjC will just be Python access to the Cocoa frameworks you learned.Overdo
P
29

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).

Precautionary answered 12/9, 2009 at 12:1 Comment(5)
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.Chromite
I haven't had that experience, I'm afraid. IB is noticing new objects, and outlets and actions in those objects quite well.Precautionary
These instructions didn't work for me until I ran the Python script referenced in the README.Koph
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.Precautionary
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.Visconti
M
4

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

Maebashi answered 27/10, 2009 at 17:49 Comment(0)
D
1

Xcode has been changed, this is the way you do it:

  1. Download the templates from https://github.com/gregneagle/Xcode4CocoaPythonTemplates

  2. Copy the two folders, File Templates and Project Templates to ~/Library/Developer/Xcode/Templates. If you don't have this folder already create it.

  3. When you open Xcode and create a new project, you will see a new section called "Cocoa-Python" with the 4 templates.

Disobedience answered 15/6, 2013 at 16:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.