PyObjC vs PyDev: debugging/running PyObjC apps.

PyObjC is a Cocoa wrapper for python. PyDev is a python development environemnt for Eclipse. You can get debugging/running of a PyObjC appilication from eclipse.
Configuring a py2app builder:
First you have to create an OSX application with py2app. For me it looks something like:
python py2app --alias --dist-dir=Debug

This will create you an OSX bundle using links to refer resources and python sources (–alias flag). This is usefull since this allows you running uptodate version of the app without reexecuting usually add this thing to the Builders of the project:

  1. Right click on the project, select Builders
  2. Press New and select Program
  3. Fill in Edit launch configuration properties:
    1. Location: /usr/bin/python
    2. Working Directory: ${project_loc}
    3. Arguments: ${} py2app –alias –dist-dir=${project_loc}/Debug

To rerun, select Clean.. from Project menu.
Configuring a PyObjC application runner:

The next step is adding a pydev runner configuration to the project.

  1. From the Run menu select Run…
  2. Select Python Run and click New…
  3. In the main tab set the following:
    1. Project: click browse and select the project
    2. Main module: select the python file containing the main code for of the PyObjC app
  4. In the environment tab set the following:
    1. CFProcessPath: ${project_loc}/Debug/
      This is needed because the OS looks for nibs and other resources in the executable’s bundle. In this case the executable is the python interpreter /usr/bin/python – so  tell CoreFoundation to look for the resources in the application package.
  5. Press apply to save the run configuration, then press Run to try it out. You should be able to debug with the same run configuration.

2 Responses to PyObjC vs PyDev: debugging/running PyObjC apps.

  1. I was wondering if this worked for you with hybrid python and obj-c apps? I’m having problems when it tries to load my Obj-c plugin- it looks like it finds the bundle but then complains that the bundle could not be loaded. Any ideas?

  2. boga says:

    It should work AFAIK. But i haven’t tried it.
    And is this only when started from eclipse with CFProcessPath trick?!
    Otherwise it’s working fine!?