23

Anybody knows how to fix PyObjC on iPhone 4s running iOS 5.0.1?

On my iPhone 4 with iOS 4.2.1 everything was working perfectly.
On the iPhone 4s with iOS 5.0.1 (and all the (same) packages installed) the PyObjC stuff does not work.

The error I get is:

File "/private/var/stash/Applications.pwn/MyPyObjC.app/MyPyObjC.py", line 9, in <module>
    import objc
  File "/usr/lib/python2.5/objc/__init__.py", line 17, in <module>
    _update()
  File "/usr/lib/python2.5/objc/__init__.py", line 14, in _update
    import _objc
ImportError: dlopen(/usr/lib/python2.5/lib-dynload/_objc.dylib, 2): Symbol not found: _OBJC_CLASS_$_Object
  Referenced from: /usr/lib/python2.5/lib-dynload/_objc.dylib
  Expected in: /usr/lib/libobjc.A.dylib

(files __init__.py & _objc.dylib are present in both devices, file libobjc.A.dylib, is missing in both devices)

Again, both iPhones have the same packages installed (but different iOS).
(as far as I know, Saurik's HelloPython.app has the same problem).

I guess they changed something in iOS 5 and the PyObjC files do not reflect the change (yet)...

I hope they will fix it... (I have 4-5 PyObjC based apps that do not work anymore) :-(

Until then, any ideas for a quick fix?

Gik
  • 528
  • 5
  • 18
  • Is still still an issue for you? I have to the same problem :( – James Kyburz Jul 21 '12 at 14:57
  • 1
    I have the same problem. The problem is that Python (or the library-loader) trys to look in `libobjc.A.dylib` which is not present. I'm not familar with iOS or Unix, but if the lib-loader was looking in the actual `_objc.dylib` (which is the native python module) it would be able to find this symbol, as it is contained in this package (try `nm _objc.dylib | grep _OBJC_CLASS_$_`). Any idea how this can be achieved? – Niklas R Aug 31 '12 at 17:11
  • @NiklasR The thing is, where can we find the "libobjc.A.dylib" file? I tried to copy the one from my Mac (as a desperate move), it did not work... And on my iPhone 4, it does not exist... :( – Gik Sep 04 '12 at 13:05
  • As `_obj.dylib` seems to expose those symbols, I have tried creating a symbolic link from `/usr/lib/libobjc.A.dylib` to `.../_objc.dylib`, but it didn't change anything. :( – Niklas R Sep 04 '12 at 17:57
  • @NiklasR The thing is that in the (old) iOS, file /usr/lib/libobjc.A.dylib did not exist, but PyObjC was working fine! – Gik Sep 04 '12 at 18:59
  • 1
    Yes, because the library-loader that loads `_objc.dylib` suddenly wants to load a `libobjc.A.dylib`, which was not the case in previous OS versions. – Niklas R Sep 04 '12 at 21:15
  • @NiklasR So it's "just" a mater of finding the "correct" libobjc.A.dylib? (Where do we find it?) – Gik Sep 18 '12 at 07:24
  • 2
    You could try contacting the developer, Ronald Oussoren, it seems he's more or less the only person working on it. The project page on SourceForge looks pretty dead, though. The latest files on sourceforge are for version 1.3.7 from 2005. Using `easy_install` you'd get version 2.3. To get a more recent version (2.4 beta), you'd have to get the subversion repository. – Roland Smith Sep 23 '12 at 13:20
  • Yes, this is something for the developer(s), and not necessarily appropriate for SO. – Dr. Jan-Philip Gehrcke Sep 23 '12 at 19:57
  • OK, Who will undertake this task guys? – Gik Sep 24 '12 at 18:56
  • IIRC, PyObjC does not work for Cocoa as Apple doesn't support a bridge between Cocoa Objective-C and Python like they supported for Carbon. I didn't look at iOS to see what is used there. – jeff.vanvoorst Sep 27 '12 at 19:53
  • I messed up, PyObjC is for Cocoa. I don't remember where I found this information, but for some recent version of OS X, Apple dropped the Objective-C Python bridge. I am unable to verify this. One would need to verify that the bridge still exists for the version of iOS you are trying to use. – jeff.vanvoorst Sep 29 '12 at 23:58
  • 1
    What about ObjP? https://bitbucket.org/hsoft/objp Just stumbled upon it, as i need Python in an iOS(the best) project, too. Did someone get it to work with iOS? See also: http://stackoverflow.com/questions/9749260/python-for-ios-interpreter – bijan Oct 18 '12 at 11:38

1 Answers1

1

Sorry PyObjec is dead since the ios 2.0 Jay Freeman abandonned the project

(btw ios wasn't made for coders/hackers and geeks buy an android phone if you want to code on your phone using the amazing SL4A api on android :) )

Arnaud Aliès
  • 1,079
  • 13
  • 26
  • 1
    Thanks for the "main" part of your answer. As for the second part, don't get me started! ... short answer: Why bother with a (new - to me) platform when I know the (almost) best platform around!? (if it was not "jailed" it would deserve the "best" title). (I would accept (and check) an answer saying: "Why don't you forget PyObjC and use the "real-thing" with XCode and Obj-C"...) – Gik Oct 15 '12 at 10:58
  • If you knew the python android api I think you wont recommend to code using java on android because its easier, faster, compilable and postable as well on google play I would love if ios had an equivalent to sl4a – Arnaud Aliès Oct 15 '12 at 11:12
  • Maybe, but I "invested" on XCode and I discovered a marvelous environment to code for (my) iPhone. After all, I am perfectly satisfied with my iPhone and I am not going to change it for an android (the same way I will not trade my Mac to (any) windows-pc). Anyway, the purpose of this thread/question was why PyObjC was broken on iOS5 (and not 2.0 - it was working fine up to 4.2.1)... – Gik Oct 15 '12 at 13:09