Issue #181 new

Need better documentation

theneedful
created an issue

I'm not new to Python, but been trying to use pyobjc, because it is basically the only library that allow interaction with Apple apps, but I'm having a very hard time understanding how to use your library. I think the library, itself, is pretty brilliant. I just can't understand the methodology to allow me to construct a pyobjc app. I can barely even do the most basic thing. Is there better documentation or training videos to help understand the syntax nad usage of this bridge? Thank you.

Comments (3)

  1. Ronald Oussoren repo owner

    Basic documentation for PyObjC is here: https://pythonhosted.org/pyobjc/core/intro.html

    What information are you looking for? PyObjC tries to be as transparent as possible, there is an easy rule for translating Objective-C selectors into Python method names (replace all colons by underscores), with some additional rules for pass-by-reference arguments (which Python doesn't have). With that it should be relatively straighforward to translate Objective-C code into Python code, although more effort is needed to make that nice Python code.

    BTW. There is a fairly large set of examples in the PyObjC repository as well as on the website. Those examples are fairly old, but should still be helpful when trying to learn how to use PyObjC.

  2. theneedful reporter

    I somewhat figured it out, based on your example page. However, the issues I guess I'm running into, that I'm finding in retrospect, is that I don't truly understand Objective-C and its syntax. Nor really have any drive to learn Objective-C, since Swift is "replacing" it. Is there a Swift bridge in the works, I wonder?

    Between a mix of your documentation, Apple's Objective-C documentation, and Dash I was able to get through a project - albeit slowly and painfully. Your work on this is pretty impressive, by my standards. Though I just wish there was a more native Python API/SDK that worked with Macs than trying to use Apple's annoying, proprietary languages.

    Thanks for the reply, but realizing my weakness was with Objective-C and not your bridge, I know what needs to be done, should I keep using your bridge. The only other way I can imagine your documentation being improved, is mirroring Apple's XCode's Objective-C documentation with what it would look like in Python. But that seems like a lot of work for a dying language, IMHO.

    I do have one last question, how do I get rid of this error message when I use your bridge? I can find suggestions for the actual language, but I can't figure out how to translate it to your bridge.

    CoreData: warning: dynamic accessors failed to find @property implementation for 'uniqueId' for entity ABCDInfo while resolving selector 'uniqueId' on class 'ABCDInfo'.  Did you remember to declare it @dynamic or @synthesized in the @implementation ?
    
  3. Ronald Oussoren repo owner

    The CoreData warning is for a class defined in an Apple framework (AddressBook by the looks of it). There is nothing you can do to fix this, apparently you're running into a bug in the AddressBook or Contacts framework.

    I agree that it would be nice to have documentation that mirror's Apple's framework documentation for use in Python, but that would be a lot of work and isn't something I can work on due to lack of time. I do think it is possible to improve the PyObjC documentation significantly without mirroring Apple's framework documentation, but that would still be a significant amount of work.

    PyObjC is intentionally a conceptually thin bridge between Python and Objective-C both to reduce the amount of work needed to keep PyObjC up-to-date (although updating the framework wrappers for new releases of macOS is still a lot off work) and to make it easier to use the wealth of existing documentation, examples, blogpost, ... to learn about Apple's APIs.

    AFAIK there is no Swift<->Python bridge and I'm not planning to work on one. I don't think having one is really necessary for the next couple of years, Swift does not yet have a stable ABI (and might not even have one for Swift 4) and without a stable ABI Apple cannot introduce Swift-only system APIs.

  4. Log in to comment