使用 Xcode 3.2 进行 PyObjC 开发
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1414727/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PyObjC development with Xcode 3.2
提问by Josh Hunt
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?
Xcode 3.2 删除了脚本语言(Ruby、Python 等)的默认模板。如何找到这些模板以在 Xcode 3.2 中使用?我是否需要向 Xcode 添加任何其他内容以支持使用和“构建”PyObjC 程序?
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?
此外,考虑到我已经是一个 Python 人,是否有任何文档和/或资源可以帮助我进入 PyObjC(和 Cocoa)?
回答by Jarret Hardie
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:
Apple 现在鼓励人们直接从 PyObjC 项目中获取模板。在Cocoabuilder 上存档了一个很好的解释线程,其中包含来自 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.
您需要从 PyObjC
存储库或网站下载并安装模板。模板是从发布中提取的,因为模板
开发的速度和时间表与 Xcode
发布的不同。很多时候,模板
在光盘被按下时已经过时了。
The PyObjC websitehas both the templates for download, and great documentation/tutorials to get up and going.
该PyObjC网站有一个用于下载的模板,和丰富的文档/教程起床去。
Edit: Being a bit more specific, here's what I have done to get PyObjC working in Snow Leopard:
编辑:更具体一点,这是我为让 PyObjC 在雪豹中工作所做的工作:
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.:
使用 Finder,我以访客身份访问
Go > Connect to Server...
并连接到http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-xcode/。然后
Xcode
我在我的本地系统上创建了一个名为~Library/Application Support/Developer/Shared/Xcode/
. (你可能已经有了这个文件夹,但我还没有为自己定制任何东西)。我将
File Templates
文件夹从红豆服务器复制到我的新 Xcode 文件夹中。将
Project Templates
文件夹复制到其他地方,例如桌面。使用终端导航到我桌面上的临时项目模板文件夹并运行此命令以“构建”模板。:
$ 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
$ cd ~/桌面/项目\模板/
$ ./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
$./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...
andNew File...
windows.
- 我启动了 Xcode。模板现在位于
New Project...
和New File...
窗口的“用户模板”部分下。
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).
开箱即用的默认项目(无需从 PyObjC 项目或 py2app 安装任何其他内容)。我用一个按钮和一个动作拼凑了一个愚蠢的程序,它运行得很漂亮,包括与 Interface Builder 的集成(我能够控制拖动来连接动作和插座)。
I also recently stumbled across a series of "Getting Started" tutorialson 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).
我最近还在一个博客上偶然发现了一系列“入门”教程,这些教程对初学者来说似乎非常有用。作者似乎在“使用 PyObjC 在 Python 中构建 Cocoa GUI”系列(目前分为 6 部分)投入了大量精力。
回答by Cory
Check out this blog posting... fixed it perfectly for me: http://ioanna.me/2009/09/installing-pyobjc-xcode-templates-in-snow-leopard/
看看这个博客帖子......为我完美地修复了它:http: //ioanna.me/2009/09/installing-pyobjc-xcode-templates-in-snow-leopard/
回答by JJW5432
Xcode has been changed, this is the way you do it:
Xcode 已更改,这是您的操作方式:
Download the templates from https://github.com/gregneagle/Xcode4CocoaPythonTemplates
Copy the two folders, File Templates and Project Templates to
~/Library/Developer/Xcode/Templates
. If you don't have this folder already create it.When you open Xcode and create a new project, you will see a new section called "Cocoa-Python" with the 4 templates.
从https://github.com/gregneagle/Xcode4CocoaPythonTemplates下载模板
将两个文件夹 File Templates 和 Project Templates 复制到
~/Library/Developer/Xcode/Templates
. 如果您还没有此文件夹,请创建它。当您打开 Xcode 并创建一个新项目时,您将看到一个名为“Cocoa-Python”的新部分,其中包含 4 个模板。