How to Use pyatv with PythonKit on iOS? Cryptography problem

  Kiến thức lập trình

I’m trying to use the pyatv library with PythonKit in my iOS app, but I’m running into several issues. I’m currently facing problems with the cryptography module, specifically with the Rust components. Here is the error message I’m receiving:
text

PythonKit/Python.swift:707: Fatal error: ‘try!’ expression unexpectedly raised an error: Python exception: dlopen(/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/cryptography/hazmat/bindings/_rust.abi3.so, 0x0002): tried: ‘/Users/kevin/Library/Developer/Xcode/DerivedData/pythontest-burgqkwtysmeqqddacdjyferjzai/Build/Products/Debug-iphonesimulator/_rust.abi3.so’ (no such file), ‘/Library/Developer/CoreSimulator/Volumes/iOS_21F79/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection/_rust.abi3.so’ (no such file), ‘/Library/Developer/CoreSimulator/Volumes/iOS_21F79/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.5.simruntime/Contents/Resources/RuntimeRoot/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/cryptography/hazmat/bindings/_rust.abi3.so’ (no such file), ‘/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/cryptography/hazmat/bindings/_rust.abi3.so’ (mach-o file (/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/cryptography/hazmat/bindings/_rust.abi3.so), but incompatible platform (have ‘macOS’, need ‘iOS-sim’))
Traceback:
File “/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/pyatvScript.py”, line 2, in
from pyatv import scan
File “/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/pyatv/init.py”, line 26, in
from pyatv.protocols import PROTOCOLS
File “/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/pyatv/protocols/init.py”, line 10, in
from pyatv.protocols import airplay as airplay_proto
File “/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/pyatv/protocols/airplay/init.py”, line 28, in
from pyatv.protocols import mrp
File “/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/pyatv/protocols/mrp/init.py”, line 14, in
from pyatv.auth.hap_srp import SRPAuthHandler
File “/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/pyatv/auth/hap_srp.py”, line 12, in
from cryptography.hazmat.primitives import hashes, serialization
File “/Users/kevin/Library/Developer/CoreSimulator/Devices/5D10560B-E4C2-4367-A773-1E8EB170E278/data/Containers/Bundle/Application/292670A7-AAEA-4B8A-B0CF-5682CA6E1AB8/pythontest.app/PythonScripts/cryptography/hazmat/primitives/hashes.py”, line 9, in
from cryptography.hazmat.bindings._rust import openssl as rust_openssl

I understand that the binary seems to be generated for macOS instead of iOS, but I’m not sure how to generate it for iOS. Has anyone successfully used pyatv with PythonKit on iOS? Any guidance on resolving these issues would be greatly appreciated!

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT