GithubHelp home page GithubHelp logo

kivy / pyobjus Goto Github PK

View Code? Open in Web Editor NEW
173.0 30.0 47.0 840 KB

Access Objective-C classes from Python

Home Page: https://pyobjus.readthedocs.io

License: MIT License

Makefile 0.21% Python 59.72% Objective-C 9.55% C 0.68% Cython 29.84%

pyobjus's Introduction

Pyobjus

Python module for accessing Objective-C classes as Python classes using Objective-C runtime reflection.

Build Status Backers on Open Collective Sponsors on Open Collective

Quick overview

from pyobjus import autoclass, objc_str
from pyobjus.dylib_manager import load_framework, INCLUDE

# load AppKit framework into pyojbus
load_framework(INCLUDE.AppKit)

# get nsalert class
NSAlert = autoclass('NSAlert')

# create an NSAlert object, and show it.
alert = NSAlert.alloc().init()
alert.setMessageText_(objc_str('Hello world!'))
alert.runModal()

Support

If you need assistance, you can ask for help on our mailing list:

We also have a Discord server:

https://chat.kivy.org/

Contributing

We love pull requests and discussing novel ideas. Check out our contribution guide and feel free to improve Pyobjus.

The following mailing list and IRC channel are used exclusively for discussions about developing the Kivy framework and its sister projects:

Discord channel:

License

Pyobjus is released under the terms of the MIT License. Please refer to the LICENSE file.

Backers

Thank you to all our backers! ๐Ÿ™ [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

pyobjus's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyobjus's Issues

Malloc/heap corruption when passing a NSRect value from python to ObjectiveC

Hello everyone,

I'm experiencing an issue with pyobjus in a Kivy project, from which I need to use the iOS content sharing API (UIKit framework), and I'm stuck because calls to this method from python causes a random malloc error.

I managed to isolate the issue, with the following minimum reproductible example:

Let's define a dummy class in ObjectiveC, with two dummy methods that take a single CGRect argument, and only logs the rect value.
One method takes its argument as a pointer, and the other as a value:

@interface foo : NSObject
@end
@implementation foo
- (void)rect_pointer:(CGRect*) rect {
    NSLog(@"rect_ref: %@", NSStringFromCGRect(*rect));
}
- (void)rect_value:(CGRect) rect {
    NSLog(@"rect: %@", NSStringFromCGRect(rect));
}
@end

When I try to access these methods from python, I have no issue with the rect_pointer method, but rect_value produces a random malloc error.

Python code:

from pyobjus import autoclass, NSRect, NSPoint, NSSize

foo = autoclass("foo")
f = foo.alloc().init()

pos = NSPoint(0,0)
size = NSSize(100, 100)
rect = NSRect(pos, size)

# this works perfectly
for i in range(10):
    f.rect_pointer_(rect)

# this fails after a random number of iterations
for i in range(10):
    f.rect_value_(rect)

I'm executing it on iOS, either on a real device (iPad mini 6th generation) or a simulator.

0
2022-12-16 15:36:35.327586+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
1
2022-12-16 15:36:35.327983+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
2
2022-12-16 15:36:35.328324+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
3
2022-12-16 15:36:35.328678+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
4
2022-12-16 15:36:35.329004+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
5
2022-12-16 15:36:35.329257+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
6
2022-12-16 15:36:35.329572+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
7
2022-12-16 15:36:35.329925+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
8
2022-12-16 15:36:35.330556+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
9
2022-12-16 15:36:35.330991+0100 cgrect[12373:506332] rect_pointer: {{0, 0}, {100, 100}}
0
2022-12-16 15:36:35.331851+0100 cgrect[12373:506332] rect_value: {{0, 0}, {0, 100}}
1
2022-12-16 15:36:35.332374+0100 cgrect[12373:506332] rect_value: {{0, 0}, {100, 100}}
2
cgrect(12373,0x102718580) malloc: Heap corruption detected, free list is damaged at 0x28031c5c0
*** Incorrect guard value: 4636737291354636288
cgrect(12373,0x102718580) malloc: *** set a breakpoint in malloc_error_break to debug
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/usr/lib/libMTLCapture.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
cgrect(12373,0x102718580) malloc: Heap corruption detected, free list is damaged at 0x28031c5c0
*** Incorrect guard value: 4636737291354636288
(lldb) 

How to pass bytes object into void* argument of a function? (NSData.dataWithBytes:length:)

Im having a hard time creating an NSData object with initializing it with my bytes. The length will be correct, however the underlying bytes will all be zero. Passing in a string creates a filled NSData object, but it will change the bytes I want to save.

My goal is to pass the bytes as they are. What am I doing wrong?

The code:

value_passed_in = b"\x01\x02\x03"
ns_data = autoclass('NSData').dataWithBytes_length_(value_passed_in, len(value_passed_in))
print(f"value passed in: {value_passed_in}")
print(f"NS data: {ns_data.description().UTF8String()}")

value_passed_in = b"12345"
ns_data = autoclass('NSData').dataWithBytes_length_(value_passed_in, len(value_passed_in))
print(f"value passed in: {value_passed_in}")
print(f"NS data: {ns_data.description().UTF8String()}")

value_passed_in = str(b"12345")
ns_data = autoclass('NSData').dataWithBytes_length_(value_passed_in, len(value_passed_in))
print(f"value passed in: {value_passed_in}")
print(f"NS data: {ns_data.description().UTF8String()}")

The output:

value passed in: b'\x01\x02\x03'
NS data: {length = 3, bytes = 0x000000}

value passed in: b'12345'


NS data: {length = 5, bytes = 0x0000000000}

value passed in: b'12345'
NS data: {length = 8, bytes = 0x6227313233343527}

I have taken a look at pull request #26 and commit 516eac6 , however I was not able to reach my goal.

figure out how to use objective-c reflection

    Class uiview_cls = objc_getClass("UIWindow");
    unsigned int num_methods = 0;
    Method* class_methods = class_copyMethodList(uiview_cls, &num_methods);
    NSLog(@"methods for UIWindow:");
    for(int i=0; i<num_methods; i++){
        const char* method_name = sel_getName(method_getName(class_methods[i]));
        const char* method_args = method_getTypeEncoding(class_methods[i]);

        NSString  *name = [NSString stringWithUTF8String:method_name];
        NSString  *args = [NSString stringWithUTF8String:method_args];
        NSLog(@"name: '%@',   type_enc: %@\n", name, args);   
    }

produces:
https://gist.github.com/3353346

Print all class of Particular Framework

I want to print all class for IOKit Framework as I'm having problem in loading Objective C classes in pyobjus.

I want to import
#import <IOKit/ps/IOPowerSources.h>
in pyobjus

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/39004884-print-all-class-of-particular-framework?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github).

Adding Python 3.x support for PyOBJus

I can install it via pip on Python 3.x, but when I run the "Hello, world" example in the doc, it fails to execute "from pyobjus import autoclass". On Python 2.x it works well. (I have tested on Python 2.7 and Python 3.5.)
I also take a look at pyobjus.pyx. Though I don't know much about Cython, I notice that it supports Python 3.x. Therefore, I hope PyOBJus could support Python 3.x, to get access to the new Python features.
The previous discussion can be found here.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/32821500-adding-python-3-x-support-for-pyobjus?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github).

Can't clone pyobjus on Windows, MS-DOS reserved word as a folder

git clone https://github.com/kivy/pyobjus

Cloning into 'pyobjus'...
remote: Enumerating objects: 219, done.
remote: Counting objects: 100% (219/219), done.
remote: Compressing objects: 100% (146/146), done.
emote: Total 1944 (delta 146), reused 131 (Receiving objects:  98% (190delta 72), pack-reused 1725
Receiving objects: 100% (1944/1944), 763.17 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1221/1221), done.
Checking connectivity... done.
fatal: cannot create directory at 'objc_classes/aux': Invalid argument
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

This is happening due to aux being a reserved MS-DOS word and the only workaround is very annoying. In case we want people to contribute to PyOBJus from Windows (e.g. docs if not the code) we'll need to rename it. That folder is most likely used on one of the iOS things hopefully only under Plyer, but I guess that something would also be available under Kivy-iOS, so it'll break things and I don't have any iOS device to test it with.

KeyError at field_list.append()

I am trying to use pyobjus to access the view with the following code:

    logging.debug("getting UIApplication")
    app_cls=autoclass("UIApplication")
    logging.debug("getting shared UIApplication obj")
    app=app_cls.sharedApplication()
    logging.debug("getting key window")
    win=app.keyWindow
    logging.debug("getting root view controller")
    ctrl=win.rootViewController()
    logging.debug("getting the view")
    vw=ctrl.view()
    logging.debug("getting the safe area insets")
    logging.debug(dir(vw))  # problem 1
    insets=vw.safeAreaInsets() # problem 2

However, it isn't working. dir(vw) returns a long blank string and calling safeAreaInsets() triggers an exception:

Traceback (most recent call last):
   File "/Users/kent/vocabassistant-ios/YourApp/main.py", line 3, in <module>
   File "/Users/kent/vocabassistant-ios/YourApp/vocab_assistant.py", line 48, in __init__
   File "/Users/kent/vocabassistant-ios/YourApp/safe_area.py", line 30, in get_safe_area
   File "pyobjus/pyobjus.pyx", line 488, in pyobjus.pyobjus.ObjcMethod.__call__
   File "pyobjus/pyobjus_conversions.pxi", line 262, in pyobjus.pyobjus.convert_cy_ret_to_py
   File "/Users/kent/Library/Developer/CoreSimulator/Devices/D196DB9F-6194-4D47-B7BD-F2DFE8670DBC/data/Containers/Bundle/Application/C9B64836-4B91-41F6-837E-B2EBFB763E2E/vocabassistant.app/lib/python3.8/site-packages/pyobjus/objc_py_types.py", line 175, in find_object
     return self.make_type(obj_type, members=members)
   File "/Users/kent/Library/Developer/CoreSimulator/Devices/D196DB9F-6194-4D47-B7BD-F2DFE8670DBC/data/Containers/Bundle/Application/C9B64836-4B91-41F6-837E-B2EBFB763E2E/vocabassistant.app/lib/python3.8/site-packages/pyobjus/objc_py_types.py", line 144, in make_type
     field_list.append((field_name, types[_type]))
 KeyError: b'd'

Error while installation: ERROR: The tar file (...) has a file (...) trying to install outside target directory (...)

My system Information:
OS: Windows 10
python --version: Python 3.7.4
pip --version: pip 20.3 from ...\kivy_venv\lib\site-packages\pip (python 3.7)
Cython.__version__: '0.29.21'

When I try to install pyobjus via pip install pyobjus I get the following error:

The tar file (C:\Users\<username>\AppData\Local\Temp\pip-unpack-7ayiqdx3\pyobjus-1.2.0.tar.gz) has a file (C:\Users\<username>\AppData\Local\Temp\pip-install-vylrktj0\pyobjus_50784346373745f7934152638e263086\objc_classes/aux) trying to install outside target directory (C:\Users\<username>\AppData\Local\Temp\pip-install-vylrktj0\pyobjus_50784346373745f7934152638e263086)

If I clone this GitHub repository and then try to run the setup.py I get the following
Pyobjus platform is win32 Traceback (most recent call last): File "setup.py", line 35, in <module> class PyObjusBuildExt(build_ext, object): NameError: name 'build_ext' is not defined

From a forum then I found the other way to install it pip install https://github.com/kivy/pyobjus/archive/master.zip
When doing that I get the following error:
`ERROR: Could not install packages due to an EnvironmentError: [WinError 267] The directory name is invalid: 'C:\Users\\AppData\Local\Temp\pip-req-build-_4lcptd1\objc_classes/aux'

I tried to find the fix for each of these errors but turned up empty-handed. Some help would be really appreciated as I need this library.

Many thanks.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/deploy.yml
  • actions/checkout v4
  • actions/setup-python v5
  • actions/upload-artifact v4
  • softprops/action-gh-release v0.1.15
.github/workflows/no-reponse.yml
  • lee-dohm/no-response 9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb
.github/workflows/python-package.yml
  • actions/checkout v4
  • actions/setup-python v5
pep621
pyproject.toml
pip_requirements
docs/requirements.txt
  • Sphinx ~=7.2.6
  • furo ==2024.5.6

  • Check this box to trigger a request for Renovate to run again on this repository

Wrong behaviour of NSArray on arm64 (but works on x86_64)

Problem:
The NSArray contains only the first element of the list on the iPhone. The NSArray is correctly set to the full list on the iPhone emulator however.

iPhone 7: iOS 1.14.1
iPhone 8 emulator: iOS 1.14

main.py:

import kivy
from kivy.app import App
from kivy.uix.label import Label
from pyobjus import autoclass, objc_arr

NSArray = autoclass('NSArray')

class MyApp(App):

    def build(self):
        shape = [1, 96, 216, 1]
        array = NSArray.arrayWithObjects_(*shape + [None])
        output_shape = [
            array.objectAtIndex_(_).intValue()
            for _ in range(array.count())
        ]
        return Label(text=f'{output_shape}')


if __name__ == '__main__':
    MyApp().run()

relevant parts of buildozer.spec:

requirements = python3,kivy,pyobjus
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.10.0

Any ideas? I am trying to set the shape of a tensor for TensorFlow Lite and I have tried everything I can think of - even casting to a ctypes pointer to ints. I'd be very grateful for any pointers (no pun intended) or workarounds. Thanks!

IndexError in type_enc.pxi

On OS X Yosemite using a PyInstaller packaged app looking like this:

#!/usr/bin/env python
from plyer import filechooser

print(filechooser.choose_dir())

I get:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/usr/local/lib/python2.7/site-packages/plyer/facades/filechooser.py", line 53, in choose_dir
  File "/usr/local/lib/python2.7/site-packages/plyer/platforms/macosx/filechooser.py", line 104, in _file_selection_dialog
  File "/usr/local/lib/python2.7/site-packages/plyer/platforms/macosx/filechooser.py", line 48, in run
  File "pyobjus.pyx", line 439, in pyobjus.ObjcMethod.__call__ (pyobjus/pyobjus.c:31580)
  File "pyobjus_conversions.pxi", line 239, in pyobjus.convert_cy_ret_to_py (pyobjus/pyobjus.c:20238)
  File "pyobjus_conversions.pxi", line 180, in pyobjus.convert_to_cy_cls_instance (pyobjus/pyobjus.c:19322)
  File "pyobjus.pyx", line 669, in pyobjus.autoclass (pyobjus/pyobjus.c:34152)
  File "pyobjus.pyx", line 482, in pyobjus.class_get_methods (pyobjus/pyobjus.c:32077)
  File "pyobjus.pyx", line 474, in pyobjus.objc_method_to_py (pyobjus/pyobjus.c:31931)
  File "pyobjus.pyx", line 181, in pyobjus.ObjcMethod.__init__ (pyobjus/pyobjus.c:28225)
  File "type_enc.pxi", line 15, in pyobjus.parse_signature (pyobjus/pyobjus.c:4228)
  File "type_enc.pxi", line 4, in pyobjus.seperate_encoding (pyobjus/pyobjus.c:3999)
IndexError: list index out of range

Did I maybe miss to package a library?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28985982-indexerror-in-type_enc-pxi?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github).

AttributeError: 'bridge' object has no attribute 'startDeviceMotion'

I am trying to use pyobjus within the spatialorientation example from plyer:

https://github.com/kivy/plyer/blob/master/examples/spatialorientation/main.py

System: macOS Monterey 12.6, Xcode 14.0.1, iPhone XS, iOS 16.0.3
Software: Plyer: 2.0.0, pyobjus: 1.2.1

However, I get the above error:

Traceback (most recent call last):
File "/Users/chris/cloud/sync/kivy/kivymd/spatialorientation-ios/YourApp/main.py", line 76, in
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/kivy/app.py", line 955, in run
runTouchApp()
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/kivy/base.py", line 574, in runTouchApp
EventLoop.mainloop()
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/kivy/base.py", line 339, in mainloop
self.idle()
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/kivy/base.py", line 383, in idle
self.dispatch_input()
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/kivy/base.py", line 334, in dispatch_input
post_dispatch_input(*pop(0))
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/kivy/base.py", line 302, in post_dispatch_input
wid.dispatch('on_touch_up', me)
File "kivy/_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/kivy/uix/behaviors/button.py", line 179, in on_touch_up
self.dispatch('on_release')
File "kivy/_event.pyx", line 727, in kivy._event.EventDispatcher.dispatch
File "kivy/_event.pyx", line 1307, in kivy._event.EventObservers.dispatch
File "kivy/_event.pyx", line 1191, in kivy._event.EventObservers._dispatch
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/kivy/lang/builder.py", line 55, in custom_callback
exec(kvlang.co_value, idmap)
File "", line 19, in
File "/Users/chris/cloud/sync/kivy/kivymd/spatialorientation-ios/YourApp/main.py", line 58, in enable_listener
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/plyer/facades/spatialorientation.py", line 43, in enable_listener
self._enable_listener()
File "/private/var/containers/Bundle/Application/D932820D-5E4D-4281-9E7B-E11CB78B2B48/spatialorientation.app/lib/python3.9/site-packages/plyer/platforms/ios/spatialorientation.py", line 18, in _enable_listener
self.bridge.startDeviceMotion()
File "pyobjus/pyobjus_types.pxi", line 640, in pyobjus.pyobjus.ObjcClassInstance.getattribute
AttributeError: 'bridge' object has no attribute 'startDeviceMotion'
2022-11-02 12:18:56.527023+0100 spatialorientation[50237:4403567] Application quit abnormally!
2022-11-02 12:18:56.554201+0100 spatialorientation[50237:4403567] Leaving

pyobjus installation error on Mac m1

ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/39/40tj234j3gdfdq_52vn1mfmw0000gn/T/tmpoun2e6nx
cwd: /private/var/folders/39/40tj234j3gdfdq_52vn1mfmw0000gn/T/pip-req-build-vngcl2fd
Complete output (57 lines):
Pyobjus platform is darwin
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-3.9
creating build/lib.macosx-10.9-universal2-3.9/pyobjus
copying pyobjus/dylib_manager.py -> build/lib.macosx-10.9-universal2-3.9/pyobjus
copying pyobjus/protocols.py -> build/lib.macosx-10.9-universal2-3.9/pyobjus
copying pyobjus/init.py -> build/lib.macosx-10.9-universal2-3.9/pyobjus
copying pyobjus/objc_py_types.py -> build/lib.macosx-10.9-universal2-3.9/pyobjus
creating build/lib.macosx-10.9-universal2-3.9/pyobjus/consts
copying pyobjus/consts/init.py -> build/lib.macosx-10.9-universal2-3.9/pyobjus/consts
copying pyobjus/consts/corebluetooth.py -> build/lib.macosx-10.9-universal2-3.9/pyobjus/consts
running build_ext
cythoning pyobjus/pyobjus.pyx to pyobjus/pyobjus.c
/private/var/folders/39/40tj234j3gdfdq_52vn1mfmw0000gn/T/pip-build-env-5mj_n5au/overlay/lib/python3.9/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/var/folders/39/40tj234j3gdfdq_52vn1mfmw0000gn/T/pip-req-build-vngcl2fd/pyobjus/pyobjus.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'pyobjus' extension
creating build/temp.macosx-10.9-universal2-3.9
creating build/temp.macosx-10.9-universal2-3.9/pyobjus
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c pyobjus/pyobjus.c -o build/temp.macosx-10.9-universal2-3.9/pyobjus/pyobjus.o
pyobjus/pyobjus.c:29384:18: warning: cast to smaller integer type 'int' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_5 = ((int)(__pyx_v_f_result[0]));
^~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29410:41: warning: cast to smaller integer type 'int' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_3 = __Pyx_PyInt_From_int(((int)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 203, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29452:45: warning: cast to smaller integer type 'char' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_2 = __Pyx_PyInt_From_int(((int)((char)(__pyx_v_f_result[0])))); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 204, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29488:39: warning: cast to smaller integer type 'int' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_int(((int)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 206, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29521:41: warning: cast to smaller integer type 'short' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_short(((short)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 208, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29620:49: warning: cast to smaller integer type 'unsigned char' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_unsigned_char(((unsigned char)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 214, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29653:48: warning: cast to smaller integer type 'unsigned int' from 'id' (aka 'struct objc_object ') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int(((unsigned int)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 216, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29686:50: warning: cast to smaller integer type 'unsigned short' from 'id' (aka 'struct objc_object ') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_unsigned_short(((unsigned short)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 218, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:30030:19: warning: cast to smaller integer type 'int' from 'id' (aka 'struct objc_object ') [-Wpointer-to-int-cast]
__pyx_t_6 = (((int)(__pyx_v_f_result[0])) != 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:43690:75: error: 'objc_msgSend_stret' is unavailable: not available in arm64
ffi_call((&__pyx_v_self->f_cif), ((void (
)(void))((id (
)(id, SEL))objc_msgSend_stret)), __pyx_v_res_ptr, __pyx_v_f_args);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:123:1: note: 'objc_msgSend_stret' has been explicitly marked unavailable here
objc_msgSend_stret(void /
id self, SEL op, ... */ )
^
9 warnings and 1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1

ERROR: Failed building wheel for pyobjus
Failed to build pyobjus
ERROR: Could not build wheels for pyobjus which use PEP 517 and cannot be installed directly

Suggestion: add ability add user defined @protocols

My understanding is that there are currently no plans to be able to handle custom blocks as a generally accepted work around seems to be to implement some bridging code in Objective C. While it would be great (and somehow satisfying) if it were possible to do everyhting from Python, I still find the need to callback my Python code. Please tell me if there is a better way of doing this without grunging around in the details of Objective C, but I am using the @protocol functionality. When an function from a Framework calls a delegate, for example, this works very well in pyobjus. Unfortunately, it doesn't seem possible to define your own delegates, so I am having to "hack" an existing one like so:

test.m:

#include <Foundation/Foundation.h>
#include <AVFoundation/AVFoundation.h>

@interface MyObjCClass : NSObject {}
+ (void) testWithDelegate: (id<AVAsynchronousKeyValueLoading>) delegate
@end

@implementation MyObjCClass
+ (void) testWithDelegate: (id<AVAsynchronousKeyValueLoading>) delegate
{
    [delegate statusOfValueForKey: @"This is a test" error: nil];
}
@end

test.py:

from pyobjus import autoclass, protocol

MyObjCClass = autoclass('MyObjCClass')

Class Test():
    def __init__(self):
        MyObjCClass.testWithDelegate_(self)

    # massive hack!
    @protocol('AVAsynchronousKeyValueLoading')
    def statusOfValueForKey_error_(self.message, error):
        Logger.info(f"{message.UTF8String()}")  # outputs "This is a test"

FWIW, I'd be happy to contribute to this project, if that is helpful. If you encourage this, are there any basic guidelines or tips I should follow?

Thanks!

bad kCFTaggedObjectID_Integer definition ?

https://github.com/kivy/pyobjus/blob/master/pyobjus/pyobjus_conversions.pxi#L188

defines it as (3 << 1) + 1

while all references i seem to find defines it as (1 << 1) + 1

http://www.crest.iu.edu/projects/conceptcpp/docs/html-ext/CGObjCMac_8cpp_source.html#l01623
http://bou.io/talks/TaggedPointersTests.html#4

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/7064670-bad-kcftaggedobjectid_integer-definition?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github).

Support for Objective-C Blocks

Hi, I stumbled upon a dead-end working with MCNearbyServiceAdvertiserDelegate. One of its required delegate methods involves an NSStackBlock, which is not callable. Is there a work around?

@protocol('MCNearbyServiceAdvertiserDelegate')
    def advertiser_didReceiveInvitationFromPeer_withContext_invitationHandler_(self, 
            advertiser, peerId, context, invitationHandler):
        invitationHandler(ObjcBool(True), self.session)

that code results in:
Exception TypeError: "'__NSStackBlock__' object is not callable" in 'pyobjus.pyobjus.protocol_forwardInvocation' ignored

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/35269647-support-for-objective-c-blocks?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github).

Second instance of Delegate crashes on iOS/MacOS

Overview

Pyobjus has the ability to specify a python class as a delegate for an Objective C call by using the @prototol decorator.

However, this will crash on a MacOS or IOS target if the delegate is referenced a second time (say by instantiating an Widget that wraps an Objective C method in two different places)

Diagnosis

The bug occurs when convert_py_to_nsobject invokes

d = objc_create_delegate(arg)

This dynamically creates an Objective C class here:

pyobjus/pyobjus/pyobjus.pyx

Lines 933 to 934 in f84a58e

cdef Class objc_cls = <Class>objc_allocateClassPair(
superclass, c_cls_name, 0)

Unfortunately, this call fails (and returns nil) when called a second time with the same c_cls_name.
Rrom the docs:

Return Value: The new class, or Nil if the class could not be created (for example, the desired name is already in use)

There's never any check for this nil, and so we eventually crash here:

objc_registerClassPair(objc_cls)

Note, there is a cache that prevents this from happening from the same python object, but here we have two separate objects, so the cache check misses:

pyobjus/pyobjus/pyobjus.pyx

Lines 924 to 927 in f84a58e

# Returns the cached delegate instance if exists for the current py_obj
# to release unused instances.
if py_obj in delegate_register:
return delegate_register[py_obj]

Fix

We should probably return the already-created class

Reproducer

Here we create a URLButton that invokes an NSURLRequest to a garbage URL when pressed. We specify the error handler (ourselves) with the a NSURLConnectionDelegate protocol handler.

Pressing either of the buttons works as expected, but if you press the second button, the app will crash.

"""
Demonstrate a bug where a second delegate with the same object name
will crash on an IOS device
"""
import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import StringProperty
from kivy.uix.button import Button
from pyobjus import autoclass, protocol, objc_str
from pyobjus.dylib_manager import load_framework, INCLUDE

load_framework(INCLUDE.Foundation)

NSURL = autoclass('NSURL')
NSURLConnection = autoclass('NSURLConnection')
NSURLRequest = autoclass('NSURLRequest')

class URLButton(Button):
    url = StringProperty(None)
    def request_connection(self):
        # This method request connection to an invalid URL so the
        # connection_didFailWithError_ protocol method will be triggered.
        url = NSURL.URLWithString_(objc_str(self.url))
        request = NSURLRequest.requestWithURL_(url)
        # Converts the Python delegate object to Objective C delegate instance
        # simply by calling the objc_delegate() function.
        connection = NSURLConnection.connectionWithRequest_delegate_(
                request, self)

        return connection

    @protocol('NSURLConnectionDelegate')
    def connection_didFailWithError_(self, connection, error):
        self.text = "NSURLConnectionDelegate:\nconn:{}\nerr:{}".format(connection,
                                                                       error)

kv = Builder.load_string("""
#:kivy 1.10.1

BoxLayout:
    orientation: 'vertical'
    URLButton:
        url: 'foo'
    URLButton:
        url: 'bar'
<URLButton>:
    url: 'abc'
    text: 'fetch {}'.format(self.url)
    on_release: self.request_connection()
    text_size: self.size
""")

class DelegateBugApp(App):
    def build(self):
        self.root = kv
        return self.root


if __name__ == "__main__":
    DelegateBugApp().run()

Pyobjus not working on Mac Catalina

When i try to install pyobjus on my mac, i receive this error, i've been struggling with this for 2 weeks and i would appreciate help.

Below is the error

Successfully installed cython-0.29.16
temitayoadefemi@Temitayos-MacBook-Air ~ % pip3 install pyobjus
Collecting pyobjus
  Using cached pyobjus-1.1.0.tar.gz (72 kB)
Building wheels for collected packages: pyobjus
  Building wheel for pyobjus (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/setup.py'"'"'; __file__='"'"'/private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-wheel-hy1qsk5y
       cwd: /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/
  Complete output (74 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.15-x86_64-3.7
  copying setup.py -> build/lib.macosx-10.15-x86_64-3.7
  creating build/lib.macosx-10.15-x86_64-3.7/pyobjus
  copying pyobjus/dylib_manager.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
  copying pyobjus/protocols.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
  copying pyobjus/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
  copying pyobjus/objc_py_types.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
  creating build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
  copying pyobjus/consts/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
  copying pyobjus/consts/corebluetooth.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
  running build_ext
  cythoning pyobjus/pyobjus.pyx to pyobjus/pyobjus.c
  /usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/pyobjus/pyobjus.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'pyobjus' extension
  creating build/temp.macosx-10.15-x86_64-3.7
  creating build/temp.macosx-10.15-x86_64-3.7/pyobjus
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/[email protected]/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c pyobjus/pyobjus.c -o build/temp.macosx-10.15-x86_64-3.7/pyobjus/pyobjus.o
  In file included from pyobjus/pyobjus.c:608:
  pyobjus/_runtime.h:33:23: error: too many arguments to function call, expected 0, have 2
    return objc_msgSend(pool, sel_registerName("init"));
           ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
  OBJC_EXPORT void
  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
  #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
  #       define OBJC_EXTERN extern
                             ^
  In file included from pyobjus/pyobjus.c:608:
  pyobjus/_runtime.h:37:22: error: too many arguments to function call, expected 0, have 2
    (void)objc_msgSend(pool, sel_registerName("drain"));
          ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
  OBJC_EXPORT void
  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
  #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
  #       define OBJC_EXTERN extern
                             ^
  pyobjus/pyobjus.c:24583:25: error: too many arguments to function call, expected 0, have 2
      (void)(objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"release"))));
             ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
  OBJC_EXPORT void
  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
  #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
  #       define OBJC_EXTERN extern
                             ^
  pyobjus/pyobjus.c:24660:45: error: too many arguments to function call, expected 0, have 2
      __pyx_v_self->o_instance = objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"retain")));
                                 ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
  OBJC_EXPORT void
  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
  #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
  #       define OBJC_EXTERN extern
                             ^
  4 errors generated.
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyobjus
  Running setup.py clean for pyobjus
Failed to build pyobjus
Installing collected packages: pyobjus
    Running setup.py install for pyobjus ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/setup.py'"'"'; __file__='"'"'/private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-record-8ig0oedo/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/pyobjus
         cwd: /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/
    Complete output (72 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.15-x86_64-3.7
    copying setup.py -> build/lib.macosx-10.15-x86_64-3.7
    creating build/lib.macosx-10.15-x86_64-3.7/pyobjus
    copying pyobjus/dylib_manager.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
    copying pyobjus/protocols.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
    copying pyobjus/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
    copying pyobjus/objc_py_types.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
    creating build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
    copying pyobjus/consts/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
    copying pyobjus/consts/corebluetooth.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
    running build_ext
    skipping 'pyobjus/pyobjus.c' Cython extension (up-to-date)
    building 'pyobjus' extension
    creating build/temp.macosx-10.15-x86_64-3.7
    creating build/temp.macosx-10.15-x86_64-3.7/pyobjus
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/[email protected]/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c pyobjus/pyobjus.c -o build/temp.macosx-10.15-x86_64-3.7/pyobjus/pyobjus.o
    In file included from pyobjus/pyobjus.c:608:
    pyobjus/_runtime.h:33:23: error: too many arguments to function call, expected 0, have 2
      return objc_msgSend(pool, sel_registerName("init"));
             ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    In file included from pyobjus/pyobjus.c:608:
    pyobjus/_runtime.h:37:22: error: too many arguments to function call, expected 0, have 2
      (void)objc_msgSend(pool, sel_registerName("drain"));
            ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    pyobjus/pyobjus.c:24583:25: error: too many arguments to function call, expected 0, have 2
        (void)(objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"release"))));
               ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    pyobjus/pyobjus.c:24660:45: error: too many arguments to function call, expected 0, have 2
        __pyx_v_self->o_instance = objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"retain")));
                                   ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    4 errors generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/setup.py'"'"'; __file__='"'"'/private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-install-_8mr0nf3/pyobjus/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-record-8ig0oedo/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/pyobjus Check the logs for full command output.
temitayoadefemi@Temitayos-MacBook-Air ~ % 

dlopen error on Foundation

On XCode 8/8.1 (on Sierra 10.12), pyobjus fails to load the foundation framework. This breaks all logs (nothing appears on the XCode console).

Got dlopen error on Foundation: dlopen(/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 1): no suitable image found.  Did find:
/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation: mach-o, but not built for iOS simulator

This used to work fine on 7.x (on Yosemite 10.10.5). The compile logs reveal no new errors during compile and libpyobjus.a builds and pyobjus functions still work on the deployed app. But logging is broken.

arm64 build fail

I get this when attempting an arm64 build (for iOS):

pyobjus/pyobjus.c:27837:55: error: 'objc_msgSend_stret' is unavailable: not available in arm64
ffi_call((&__pyx_v_self->f_cif), ((void (*)(void))objc_msgSend_stret), __pyx_v_res_ptr, __pyx_v_f_args);
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/include/objc/message.h:128:18: note:
'objc_msgSend_stret' has been explicitly marked unavailable here
OBJC_EXPORT void objc_msgSend_stret(id self, SEL op, ...)
^
1 error generated.

Error installing Pyobjus. super() takes at least 1 argument (0 given)

Collecting git+http://github.com/kivy/pyobjus/
Cloning http://github.com/kivy/pyobjus/ to /private/var/folders/2h/dzn2_c9x24d9mlcjtbfdb6080000gn/T/pip-req-build-iAPiXA
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: pyobjus
Building wheel for pyobjus (PEP 517) ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/2h/dzn2_c9x24d9mlcjtbfdb6080000gn/T/tmpPwI2JN:
Pyobjus platform is darwin
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-2.7
creating build/lib.macosx-10.9-x86_64-2.7/pyobjus
copying pyobjus/dylib_manager.py -> build/lib.macosx-10.9-x86_64-2.7/pyobjus
copying pyobjus/protocols.py -> build/lib.macosx-10.9-x86_64-2.7/pyobjus
copying pyobjus/init.py -> build/lib.macosx-10.9-x86_64-2.7/pyobjus
copying pyobjus/objc_py_types.py -> build/lib.macosx-10.9-x86_64-2.7/pyobjus
creating build/lib.macosx-10.9-x86_64-2.7/pyobjus/consts
copying pyobjus/consts/init.py -> build/lib.macosx-10.9-x86_64-2.7/pyobjus/consts
copying pyobjus/consts/corebluetooth.py -> build/lib.macosx-10.9-x86_64-2.7/pyobjus/consts
running build_ext
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in
main()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 141, in build_wheel
metadata_directory)
File "/private/var/folders/2h/dzn2_c9x24d9mlcjtbfdb6080000gn/T/pip-build-env-0NBeh5/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 209, in build_wheel
wheel_directory, config_settings)
File "/private/var/folders/2h/dzn2_c9x24d9mlcjtbfdb6080000gn/T/pip-build-env-0NBeh5/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 194, in _build_with_temp_dir
self.run_setup()
File "/private/var/folders/2h/dzn2_c9x24d9mlcjtbfdb6080000gn/T/pip-build-env-0NBeh5/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 243, in run_setup
self).run_setup(setup_script=setup_script)
File "/private/var/folders/2h/dzn2_c9x24d9mlcjtbfdb6080000gn/T/pip-build-env-0NBeh5/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 142, in run_setup
exec(compile(code, file, 'exec'), locals())
File "setup.py", line 123, in
'Topic :: Software Development :: Libraries :: Application Frameworks'
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/private/var/folders/2h/dzn2_c9x24d9mlcjtbfdb6080000gn/T/pip-build-env-0NBeh5/overlay/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
self.run_command(cmd_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/private/var/folders/2h/dzn2_c9x24d9mlcjtbfdb6080000gn/T/pip-build-env-0NBeh5/overlay/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "setup.py", line 50, in build_extensions
super().build_extensions()
TypeError: super() takes at least 1 argument (0 given)

How to Load Custom Classes for iOS (besides bridge.m)?

According to the documentation for iOS, it is currently possible to:

...add additional bridge methods to your pyobjus iOS app by changing the content of the bridge.m/.h files, or by adding completely new files and classes to your xcode project

I am able to successfully edit the bridge.m file and get expected results. However, when I add a new class (per this documentation demo) in my XCode project (right next to bridge.m and bridge.h), I am not able to load it:

from pyobjus.dylib_manager import load_framework, make_dylib, load_dylib, INCLUDE

make_dylib('objc_lib.m', out='objc_lib.dylib', frameworks=['Foundation'])
load_dylib('objc_lib.dylib') # I also tested just running autoclass without dylib methods before hand
ObjcClass = autoclass('objc_lib')
ObjcClass.alloc().init().printFromObjectiveC()

The error I get when trying to load any other class besides bridge.m is:

YourApp/main.py", line 20, in <module>
   File "/Users/me/kivy-ios/build/pyobjus/i386/pyobjus-master/iosbuild/lib/python2.7/site-packages/pyobjus/dylib_manager.py", line 56, in make_dylib
   File "/Users/me/kivy-ios/dist/root/python/lib/python2.7/subprocess.py", line 486, in call
   File "/Users/me/kivy-ios/dist/root/python/lib/python2.7/subprocess.py", line 672, in __init__
   File "/Users/me/kivy-ios/dist/root/python/lib/python2.7/subprocess.py", line 1112, in _execute_child
 OSError: [Errno 1] Operation not permitted
2016-06-18 14:28:40.577 theApp[3280:1386652] Application quit abnormally!
2016-06-18 14:28:40.628 theApp[3280:1386652] Leaving

Why can I edit and load bridge.m but not any other class? How can I load custom classes besides bridge.m for iOS through pyobjus?

EXC_BAD_ACCESS code=1 address=0x1 when accepting multipeer connection

Hi,

I am simply using a MCAdvertiserAssistant and when a single connection is made, which ever device accepted the connection crashes with the following debug point in the code:

EXC_BAD_ACCESS code=1 address=0x1

  /* "pyobjus/pyobjus_conversions.pxi":164
 *     dprint("convert_to_cy_cls_instance: {0}".format(pr(ret_id)))
 *     cdef ObjcClassInstance cret
 *     bret = <bytes><char *>object_getClassName(ret_id)             # <<<<<<<<<<<<<<
 *     dprint(' - object_getClassName(f_result) =', bret)
 *     if bret == 'nil':
 */
  __pyx_t_1 = __Pyx_PyBytes_FromString(((char *)object_getClassName(__pyx_v_ret_id))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_t_1;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_bret = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

If you decline the invitation this error does not occur (trivial case). I have tried running the zombie profiler, but this issue does not get caught as a zombie. It appears though that something is assumed stored in address "1", so I'm wondering if somewhere in pyobjus it is passing a hard-coded value of "1" rather than the pointer of correct type.

Is anyone familiar with this issue? It is highly reproducible, for instance:

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.clock import Clock
from pyobjus import autoclass, protocol
from pyobjus.dylib_manager import load_framework
from datetime import datetime

from pyobjus import autoclass

load_framework('/System/Library/Frameworks/Foundation.framework')
load_framework('/System/Library/Frameworks/MultipeerConnectivity.framework')
NSString = autoclass('NSString')

NSUTF8StringEncoding = 4


class MCManager:

    def __init__(self):
        # get a random unique display name
        self.displayname = NSString.stringWithUTF8String_('pp' + str(datetime.now())[20:])
        self.serviceName = NSString.stringWithUTF8String_('chat-files')
        self.peerId = autoclass('MCPeerID').alloc().initWithDisplayName_(self.displayname)


        self.ad_session = autoclass('MCSession').alloc().initWithPeer_(self.peerId)
        self.ad_session.setDelegate_(self)

        self.browse_session = autoclass('MCSession').alloc().initWithPeer_(self.peerId)
        self.browse_session.setDelegate_(self)

        self.advertiser = autoclass('MCAdvertiserAssistant').alloc().initWithServiceType_discoveryInfo_session_(
            self.serviceName, None, self.ad_session)
        self.advertiser.start()

        self.browser = autoclass('MCNearbyServiceBrowser').alloc().initWithPeer_serviceType_(
            self.peerId, self.serviceName)
        self.browser.setDelegate_(self)
        self.browser.startBrowsingForPeers()

    @protocol('MCSessionDelegate')
    def session_peer_didChangeState_(self, session, peerID, state):
        pass

    @protocol('MCNearbyServiceBrowserDelegate')
    def browser_foundPeer_withDiscoveryInfo_(self, browser, peerId, discoveryInfo):
        print("found!", peerId, discoveryInfo)
        print str(self.peerId.hash())
        if self.peerId.hash() < peerId.hash():
            print("INVITING")
            browser.invitePeer_toSession_withContext_timeout_(peerId, self.browse_session, None, 30)
        else:
            print "awaiting invite instead"


class BasicWidget(Widget):
    mc = MCManager()


class BasicApp(App):
    def build(self):
        game = BasicWidget()
        return game


if __name__ == '__main__':
    BasicApp().run()

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/35287028-exc_bad_access-code-1-address-0x1-when-accepting-multipeer-connection?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github).

How i can load NSString data by pointer with objc_str in pyobjus?

Can you help me and say how i can read NSString data by pointer into objc_str?

import ctypes
test_dylib = ctypes.cdll.LoadLibrary("test.dylib")
getUsername = test_dylib.getUsername
getUsername.restype = ctypes.c_char_p

getUsername() return pointer to NSString *function:

NSString *getUsername() {
return @"abc";
}

And I need something like
print objc_str(*getUsername).UTF8String()

error when compiling Kivy on Xcode due to pyobjus

when I want tu run Kivy iOS on Xcode, I have this error on target output. Please help
thanks

" Traceback (most recent call last):
File "/XXXXX/XXXXX/PycharmProjects/kivy-ios/prod-ios/YourApp/main.py", line 592, in
File "/XXXXXXXX/XXXXXXX/Library/Developer/CoreSimulator/Devices/FF2C200F-D939-4874-AF94-FB1E69041947/data/Containers/Bundle/Application/622F6B7C-C50F-4BAF-B2B0-6CE748527586/prod.app/lib/python3.8/site-packages/kivy/app.py", line 949, in run
self._run_prepare()
File "/XXXXX/XXXXXXX/Library/Developer/CoreSimulator/Devices/FF2C200F-D939-4874-AF94-FB1E69041947/data/Containers/Bundle/Application/622F6B7C-C50F-4BAF-B2B0-6CE748527586/prod.app/lib/python3.8/site-packages/kivy/app.py", line 944, in _run_prepare
self.dispatch('on_start')
File "kivy/_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/Users/proprietaire/PycharmProjects/kivy-ios/prod-ios/YourApp/main.py", line 131, in on_start
File "pyobjus/pyobjus.pyx", line 740, in pyobjus.pyobjus.autoclass
File "pyobjus/pyobjus.pyx", line 98, in pyobjus.pyobjus.MetaObjcClass.new
File "pyobjus/pyobjus.pyx", line 129, in pyobjus.pyobjus.MetaObjcClass.resolve_class
pyobjus.pyobjus.ObjcException: Unable to find class b'adSwitch'

Objective-C iOS 13.0 breaking changes

As mentioned on discord, a user tried to build pyobjus via kivy-ios with latest XCode11 and iOS SDK 13.0.

Here the full trace I had from the user:
https://pastebin.com/ajbfyA6i

Some diff reference (from iOS 12.4 to iOS 13.0): http://codeworkshop.net/objc-diff/sdkdiffs/ios/13.0/Objective-C.html

Apple Developer docs still mentions params, but have void in declaration: https://developer.apple.com/documentation/objectivec/1456712-objc_msgsend

Edit:
Current workaround is switching back to XCode 10.3

When trying to install Pyobjus: NameError: name 'build_ext' is not defined

I am trying to install Pyobjus in a Python venv on an Ubuntu 20.04 linux.
In Termintal I activate the venv, then I go to the directory where I unpacked 'pyobjus-master'. There I have tried different install methods, but they all result in variations of this:

Traceback (most recent call last):
  File "setup.py", line 35, in <module>
    class PyObjusBuildExt(build_ext, object):
NameError: name 'build_ext' is not defined

What am I doing wrong?

PS: The venv has a large amount of packages installed, and all up-to-date, including:
setuptools 54.1.2
cython 0.29.22
(Someone mentioned them in another issue. That's why I mention them here.)

PPS: My real goal is to be able to export/share a file from a Kivy app to other apps on iOS/iPhone. I am willing to pay someone for making that possible!

Please help!

'objc_msgSend_stret' is unavailable: not available in arm64

I am trying to install pyobjus in my mac running big sur. I am getting this error while installing.
Here is the error log:

Pyobjus platform is darwin
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-3.10
creating build/lib.macosx-10.9-universal2-3.10/pyobjus
copying pyobjus/dylib_manager.py -> build/lib.macosx-10.9-universal2-3.10/pyobjus
copying pyobjus/protocols.py -> build/lib.macosx-10.9-universal2-3.10/pyobjus
copying pyobjus/init.py -> build/lib.macosx-10.9-universal2-3.10/pyobjus
copying pyobjus/objc_py_types.py -> build/lib.macosx-10.9-universal2-3.10/pyobjus
creating build/lib.macosx-10.9-universal2-3.10/pyobjus/consts
copying pyobjus/consts/init.py -> build/lib.macosx-10.9-universal2-3.10/pyobjus/consts
copying pyobjus/consts/corebluetooth.py -> build/lib.macosx-10.9-universal2-3.10/pyobjus/consts
running build_ext
cythoning pyobjus/pyobjus.pyx to pyobjus/pyobjus.c
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /Users/kirito/Downloads/pyobjus-master/pyobjus/pyobjus.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'pyobjus' extension
creating build/temp.macosx-10.9-universal2-3.10
creating build/temp.macosx-10.9-universal2-3.10/pyobjus
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c pyobjus/pyobjus.c -o build/temp.macosx-10.9-universal2-3.10/pyobjus/pyobjus.o
pyobjus/pyobjus.c:29384:18: warning: cast to smaller integer type 'int' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_5 = ((int)(__pyx_v_f_result[0]));
^~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29410:41: warning: cast to smaller integer type 'int' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_3 = __Pyx_PyInt_From_int(((int)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 203, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29452:45: warning: cast to smaller integer type 'char' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_2 = __Pyx_PyInt_From_int(((int)((char)(__pyx_v_f_result[0])))); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 204, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29488:39: warning: cast to smaller integer type 'int' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_int(((int)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 206, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29521:41: warning: cast to smaller integer type 'short' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_short(((short)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 208, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29620:49: warning: cast to smaller integer type 'unsigned char' from 'id' (aka 'struct objc_object *') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_unsigned_char(((unsigned char)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 214, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29653:48: warning: cast to smaller integer type 'unsigned int' from 'id' (aka 'struct objc_object ') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int(((unsigned int)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 216, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:29686:50: warning: cast to smaller integer type 'unsigned short' from 'id' (aka 'struct objc_object ') [-Wpointer-to-int-cast]
__pyx_t_4 = __Pyx_PyInt_From_unsigned_short(((unsigned short)(__pyx_v_f_result[0]))); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 218, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:30030:19: warning: cast to smaller integer type 'int' from 'id' (aka 'struct objc_object ') [-Wpointer-to-int-cast]
__pyx_t_6 = (((int)(__pyx_v_f_result[0])) != 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~
pyobjus/pyobjus.c:43690:75: error: 'objc_msgSend_stret' is unavailable: not available in arm64
ffi_call((&__pyx_v_self->f_cif), ((void (
)(void))((id (
)(id, SEL))objc_msgSend_stret)), __pyx_v_res_ptr, __pyx_v_f_args);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:123:1: note: 'objc_msgSend_stret' has been explicitly marked unavailable here
objc_msgSend_stret(void /
id self, SEL op, ... */ )
^
9 warnings and 1 error generated.
error: command '/usr/bin/clang' failed with exit code 1

`pip install pyobjus` fails on Mac OSX

Running pip install pyobjus fails on mac with the following errors:

(mb_pc_env) Vik-MBP:multibeam_pointcloud_correction vik748$ pip install pyobjus
Collecting pyobjus
  Using cached https://files.pythonhosted.org/packages/cb/9e/6425d66cf66892ee99ebdc86204c825d6817458328b6cdc3a6c51ad152d1/pyobjus-1.1.0.tar.gz
Building wheels for collected packages: pyobjus
  Running setup.py bdist_wheel for pyobjus ... error
  Complete output from command /Users/vik748/anaconda3/envs/mb_pc_env/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qq/p75542c55gz41w8ycl_crgq40000gn/T/pip-install-6mtj74f6/pyobjus/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/qq/p75542c55gz41w8ycl_crgq40000gn/T/pip-wheel-ldrgr6ie --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.6-x86_64-3.5
  copying setup.py -> build/lib.macosx-10.6-x86_64-3.5
  creating build/lib.macosx-10.6-x86_64-3.5/pyobjus
  copying pyobjus/dylib_manager.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus
  copying pyobjus/protocols.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus
  copying pyobjus/__init__.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus
  copying pyobjus/objc_py_types.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus
  creating build/lib.macosx-10.6-x86_64-3.5/pyobjus/consts
  copying pyobjus/consts/__init__.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus/consts
  copying pyobjus/consts/corebluetooth.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus/consts
  running build_ext
  cythoning pyobjus/pyobjus.pyx to pyobjus/pyobjus.c
  /Users/vik748/anaconda3/envs/mb_pc_env/lib/python3.5/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/var/folders/qq/p75542c55gz41w8ycl_crgq40000gn/T/pip-install-6mtj74f6/pyobjus/pyobjus/pyobjus.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'pyobjus' extension
  creating build/temp.macosx-10.6-x86_64-3.5
  creating build/temp.macosx-10.6-x86_64-3.5/pyobjus
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/vik748/anaconda3/envs/mb_pc_env/include -arch x86_64 -I/Users/vik748/anaconda3/envs/mb_pc_env/include/python3.5m -c pyobjus/pyobjus.c -o build/temp.macosx-10.6-x86_64-3.5/pyobjus/pyobjus.o
  In file included from pyobjus/pyobjus.c:608:
  pyobjus/_runtime.h:33:23: error: too many arguments to function call, expected 0, have 2
    return objc_msgSend(pool, sel_registerName("init"));
           ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
  OBJC_EXPORT void
  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
  #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
  #       define OBJC_EXTERN extern
                             ^
  In file included from pyobjus/pyobjus.c:608:
  pyobjus/_runtime.h:37:22: error: too many arguments to function call, expected 0, have 2
    (void)objc_msgSend(pool, sel_registerName("drain"));
          ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
  OBJC_EXPORT void
  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
  #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
  #       define OBJC_EXTERN extern
                             ^
  pyobjus/pyobjus.c:24591:25: error: too many arguments to function call, expected 0, have 2
      (void)(objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"release"))));
             ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
  OBJC_EXPORT void
  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
  #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
  #       define OBJC_EXTERN extern
                             ^
  pyobjus/pyobjus.c:24668:45: error: too many arguments to function call, expected 0, have 2
      __pyx_v_self->o_instance = objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"retain")));
                                 ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
  OBJC_EXPORT void
  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
  #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
  #       define OBJC_EXTERN extern
                             ^
  4 errors generated.
  error: command 'gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for pyobjus
  Running setup.py clean for pyobjus
Failed to build pyobjus
Installing collected packages: pyobjus
  Running setup.py install for pyobjus ... error
    Complete output from command /Users/vik748/anaconda3/envs/mb_pc_env/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qq/p75542c55gz41w8ycl_crgq40000gn/T/pip-install-6mtj74f6/pyobjus/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/qq/p75542c55gz41w8ycl_crgq40000gn/T/pip-record-5jpuhtqs/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-x86_64-3.5
    copying setup.py -> build/lib.macosx-10.6-x86_64-3.5
    creating build/lib.macosx-10.6-x86_64-3.5/pyobjus
    copying pyobjus/dylib_manager.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus
    copying pyobjus/protocols.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus
    copying pyobjus/__init__.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus
    copying pyobjus/objc_py_types.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus
    creating build/lib.macosx-10.6-x86_64-3.5/pyobjus/consts
    copying pyobjus/consts/__init__.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus/consts
    copying pyobjus/consts/corebluetooth.py -> build/lib.macosx-10.6-x86_64-3.5/pyobjus/consts
    running build_ext
    skipping 'pyobjus/pyobjus.c' Cython extension (up-to-date)
    building 'pyobjus' extension
    creating build/temp.macosx-10.6-x86_64-3.5
    creating build/temp.macosx-10.6-x86_64-3.5/pyobjus
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/vik748/anaconda3/envs/mb_pc_env/include -arch x86_64 -I/Users/vik748/anaconda3/envs/mb_pc_env/include/python3.5m -c pyobjus/pyobjus.c -o build/temp.macosx-10.6-x86_64-3.5/pyobjus/pyobjus.o
    In file included from pyobjus/pyobjus.c:608:
    pyobjus/_runtime.h:33:23: error: too many arguments to function call, expected 0, have 2
      return objc_msgSend(pool, sel_registerName("init"));
             ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    In file included from pyobjus/pyobjus.c:608:
    pyobjus/_runtime.h:37:22: error: too many arguments to function call, expected 0, have 2
      (void)objc_msgSend(pool, sel_registerName("drain"));
            ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    pyobjus/pyobjus.c:24591:25: error: too many arguments to function call, expected 0, have 2
        (void)(objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"release"))));
               ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    pyobjus/pyobjus.c:24668:45: error: too many arguments to function call, expected 0, have 2
        __pyx_v_self->o_instance = objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"retain")));
                                   ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    4 errors generated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------

Support for Swift code?

If I want to write part of my project is Swift. Is it possible to integrate with a Kivy app?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/41948961-support-for-swift-code?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github).

Cant install pyobjus on MacOS 10.15.3

i tried import pyobjus to my pycharm project and this is the error i recieved, can anyone advise me on what i can do. i already have cython installed in the project

Collecting pyobjus
  Using cached https://files.pythonhosted.org/packages/cb/9e/6425d66cf66892ee99ebdc86204c825d6817458328b6cdc3a6c51ad152d1/pyobjus-1.1.0.tar.gz
Installing collected packages: pyobjus
  Running setup.py install for pyobjus: started
    Running setup.py install for pyobjus: finished with status 'error'
    Complete output from command /Users/temitayoadefemi/tesr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pycharm-packaging/pyobjus/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-record-0_9n51m8/install-record.txt --single-version-externally-managed --compile --install-headers /Users/temitayoadefemi/tesr/include/site/python3.7/pyobjus:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.15-x86_64-3.7
    copying setup.py -> build/lib.macosx-10.15-x86_64-3.7
    creating build/lib.macosx-10.15-x86_64-3.7/pyobjus
    copying pyobjus/dylib_manager.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
    copying pyobjus/protocols.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
    copying pyobjus/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
    copying pyobjus/objc_py_types.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus
    creating build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
    copying pyobjus/consts/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
    copying pyobjus/consts/corebluetooth.py -> build/lib.macosx-10.15-x86_64-3.7/pyobjus/consts
    warning: build_py: byte-compiling is disabled, skipping.
    
    running build_ext
    cythoning pyobjus/pyobjus.pyx to pyobjus/pyobjus.c
    /Users/temitayoadefemi/tesr/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pycharm-packaging/pyobjus/pyobjus/pyobjus.pyx
      tree = Parsing.p_module(s, pxd, full_module_name)
    building 'pyobjus' extension
    creating build/temp.macosx-10.15-x86_64-3.7
    creating build/temp.macosx-10.15-x86_64-3.7/pyobjus
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/[email protected]/include -I/usr/local/opt/sqlite/include -I/Users/temitayoadefemi/tesr/include -I/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c pyobjus/pyobjus.c -o build/temp.macosx-10.15-x86_64-3.7/pyobjus/pyobjus.o
    In file included from pyobjus/pyobjus.c:608:
    pyobjus/_runtime.h:33:23: error: too many arguments to function call, expected 0, have 2
      return objc_msgSend(pool, sel_registerName("init"));
             ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    In file included from pyobjus/pyobjus.c:608:
    pyobjus/_runtime.h:37:22: error: too many arguments to function call, expected 0, have 2
      (void)objc_msgSend(pool, sel_registerName("drain"));
            ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    pyobjus/pyobjus.c:24583:25: error: too many arguments to function call, expected 0, have 2
        (void)(objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"release"))));
               ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    pyobjus/pyobjus.c:24660:45: error: too many arguments to function call, expected 0, have 2
        __pyx_v_self->o_instance = objc_msgSend(__pyx_v_self->o_instance, sel_registerName(((char *)"retain")));
                                   ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/message.h:62:1: note: 'objc_msgSend' declared here
    OBJC_EXPORT void
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:236:25: note: expanded from macro 'OBJC_EXPORT'
    #   define OBJC_EXPORT  OBJC_EXTERN OBJC_VISIBLE
                            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/objc/objc-api.h:225:28: note: expanded from macro 'OBJC_EXTERN'
    #       define OBJC_EXTERN extern
                               ^
    4 errors generated.
    error: command 'clang' failed with exit status 1
    
    ----------------------------------------

Command "/Users/temitayoadefemi/tesr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pycharm-packaging/pyobjus/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pip-record-0_9n51m8/install-record.txt --single-version-externally-managed --compile --install-headers /Users/temitayoadefemi/tesr/include/site/python3.7/pyobjus" failed with error code 1 in /private/var/folders/7z/tyb3y9hd2b30lg4fml_bwf880000gn/T/pycharm-packaging/pyobjus/

doc broken on readthedoc

https://readthedocs.org/builds/pyobjus/1138591/

/var/build/user_builds/pyobjus/checkouts/latest/docs/source/api.rst:166: WARNING: Title underline too short.

Pyobjus Objective C types
-------------
/var/build/user_builds/pyobjus/checkouts/latest/docs/source/api.rst:166: WARNING: Title underline too short.

Pyobjus Objective C types
-------------
/var/build/user_builds/pyobjus/checkouts/latest/docs/source/api.rst:267: WARNING: using old C markup; please migrate to new-style markup (e.g. c:function instead of cfunction), see http://sphinx-doc.org/domains.html
/var/build/user_builds/pyobjus/checkouts/latest/docs/source/api.rst:4: SEVERE: Duplicate ID: "module-pyobjus.objc_py_types".
/var/build/user_builds/pyobjus/checkouts/latest/docs/source/api.rst:384: WARNING: Inline emphasis start-string without end-string.
/var/build/user_builds/pyobjus/checkouts/latest/docs/source/quickstart.rst:11: WARNING: Title underline too short.

The simplest example
-----------------
WARNING: html_static_path entry u'/var/build/user_builds/pyobjus/checkouts/latest/docs/source/_static' does not exist

nameerror: name 'build_ext' is not defined during installation on linux

is there any way to solve that problem with installation on linux ?

ERROR: Command errored out with exit status 1: command: /root/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lm35sz6r/pyobjus/setup.py'"'"'; _file__='"'"'/tmp/pip-install-lm35sz6r/pyobjus/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file_);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, _file_, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-lm35sz6r/pyobjus/pip-egg-info cwd: /tmp/pip-install-lm35sz6r/pyobjus/ Complete output (5 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-lm35sz6r/pyobjus/setup.py", line 58, in <module> cmdclass={'build_ext': build_ext}, NameError: name 'build_ext' is not defined

Camera usage with pyobjus

Hi, guys!

Do you have an example of a very simple camera implementation? If no, can you add it?
Is it possible to create camera app with pyobjus at all? :-)

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/5908292-camera-usage-with-pyobjus?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github).

autoclass('NSString', ... ) => 'TypeError: expected bytes, str found'

After converting the Print() statements in https://github.com/kivy/pyobjus/blob/master/examples/using_autoclass.py from Python2 to Python3 I deployed it on the iPhone 7 simulator in Xcode ver. 12.4 on MacOS Catalina ver. 10.15.7. The first few statements work fine, but line 17:

NSString = autoclass('NSString', load_class_methods=['alloc'], load_instance_methods=['init', 'initWithString:', 'UTF8String'])

results in this error:

Traceback (most recent call last):
  File "/Users/henrik/pyobjus-original-example-ny-ios/YourApp/main.py", line 17, in <module>
  File "pyobjus/pyobjus.pyx", line 719, in pyobjus.pyobjus.autoclass
  File "pyobjus/pyobjus.pyx", line 556, in pyobjus.pyobjus.class_get_partial_methods
TypeError: expected bytes, str found
2021-03-19 20:57:08.013155+0100 pyobjus-original-example-ny[12926:512737] Application quit abnormally!
2021-03-19 20:57:08.021033+0100 pyobjus-original-example-ny[12926:512737] Leaving

'error: Unsupported architecture' when trying to install on Mac OS X Catalina 10.15.7

I am trying to install PyObjus on a MacBook (Mid 2012) running OS X Catalina ver. 10.15.7.
In Terminal I activate my Python venv and go to the 'pyobjus-master' directory where I unpacked the zip file. Then I try:

(venv) henrik@MBPtilhdeHenrik pyobjus-master % python setup.py install   

Here is the start of the error output:

(venv) henrik@MBPtilhdeHenrik pyobjus-master % python setup.py install 
Pyobjus platform is darwin
running install
running build
running build_py
running build_ext
skipping 'pyobjus/pyobjus.c' Cython extension (up-to-date)
building 'pyobjus' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -I/Users/henrik/Python-Kivy/Geo-ESP/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c pyobjus/pyobjus.c -o build/temp.macosx-10.14.6-x86_64-3.8/pyobjus/pyobjus.o
In file included from pyobjus/pyobjus.c:4:
In file included from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/Python.h:11:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/limits.h:21:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/limits.h:63:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
 ^
In file included from pyobjus/pyobjus.c:4:
In file included from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/Python.h:11:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/limits.h:21:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/limits.h:64:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/machine/limits.h:8:2: error: architecture not supported
#error architecture not supported
 ^

From there it's just 18 similar errors, then:

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command 'clang' failed with exit status 1

I also tried:

% python3 setup.py install

And even:

% pip3 install pyobjus

And:

% python3 setup.py install --user

Please help! Thank you!

Actually I feel that my Kivy app is important for the future of mankind...! And it can't work without exporting a data file to be opened by other apps. For that I guess I need PyObjus.

I am willing to pay someone to create a file export/share module for Python-Kivy-iOS!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.