ColdGrub1384 / LibTerm

iOS sandboxed terminal with Python, Lua and Clang
https://libterm.app
MIT License
639 stars 115 forks source link

Using Objective-C on Libterm #63

Closed ongyx closed 2 years ago

ongyx commented 4 years ago

It would be cool if there was a way to access Objective-C frameworks from Python, so I did some investigation:

I installed rubicon-objc, a pure-Python binding for Objective-C through pip (used in Pyto). I got as far as this:

>>> import faulthandler
>>> from rubicon.objc import *
>>> faulthandler.enable()
>>> NSUserDefaults = ObjCClass("NSUserDefaults").alloc().init()

Fatal Python error: Bus error

Current thread 0x000000016f243000 (most recent call first):
  File "/var/mobile/Containers/Data/Application/7BE8E4B2-65E6-48FE-8610-1BA5866D66BB/Documents/site-packages3/rubicon/objc/runtime.py", line 610 in send_message
  File "/var/mobile/Containers/Data/Application/7BE8E4B2-65E6-48FE-8610-1BA5866D66BB/Documents/site-packages3/rubicon/objc/api.py", line 516 in __new__
  File "/var/mobile/Containers/Data/Application/7BE8E4B2-65E6-48FE-8610-1BA5866D66BB/Documents/site-packages3/rubicon/objc/api.py", line 1022 in py_from_ns
  File "/var/mobile/Containers/Data/Application/7BE8E4B2-65E6-48FE-8610-1BA5866D66BB/Documents/site-packages3/rubicon/objc/api.py", line 147 in __call__
  File "/var/mobile/Containers/Data/Application/7BE8E4B2-65E6-48FE-8610-1BA5866D66BB/Documents/site-packages3/rubicon/objc/api.py", line 206 in __call__
  File "test.py", line 6 in <module>
bus error

A bus error points to an issue with memory; it could be a invalid pointer (a problem with ctypes, maybe). Loading other Objective-C classes also results in this.