kivy / kivy-ios

Toolchain for compiling Python / Kivy / other libraries for iOS
https://kivy.org/docs/guide/packaging-ios.html
MIT License
781 stars 240 forks source link

Python error after building to iPhone Simulator #923

Closed the-JACK-pot closed 6 months ago

the-JACK-pot commented 6 months ago

Versions

Describe the bug In Xcode, after clicking the 'build' button, the simulator opens up successfully and a 'Build Successful' message appears. After the app is installed and opened in the simulator, it crashes after a second or two, and produces the Logs shown below.

To Reproduce I created my Xcode project and python venv within the kivy-ios, which I downloaded and installed from GitHub directly. I'm using python 3.11.6 because my Xcode project always seems to end up with 3.11.6 regardless of if the venv was in version 3.12 . I built the necessary recipes (apart from cymunk, zbarlight, and 2 others since I file within kivy-ios had a comment which mentioned them not working, which they didn't so I left them) and then built the project. It built perfectly fine, but always produces this. I should mention that the Library Foundation says it's installed in the system, since it's mentioned a lot in the Logs.

Expected behavior For Python, and therefore the app itself, to not crash when opening it on the iPhone Simulator.

Logs

Logging Error: Failed to initialize logging system. Log messages may be missing. If this issue persists, try setting IDEPreferLogStreaming=YES in the active scheme actions environment variables.
Available orientation: KIVY_ORIENTATION=LandscapeLeft LandscapeRight Portrait PortraitUpsideDown
Initializing python
<string>:1: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
Running main.py: /Users/jack/Library/Developer/CoreSimulator/Devices/99A60CC7-AFB9-457C-A0E2-BB253DD5790A/data/Containers/Bundle/Application/B7A39577-838D-4A52-8C3B-F6B545B497D9/grooveid.app/YourApp/main.pyc
[INFO   ] [Logger      ] Record log in /Users/jack/Library/Developer/CoreSimulator/Devices/99A60CC7-AFB9-457C-A0E2-BB253DD5790A/data/Containers/Data/Application/31A3DAE8-621B-45DE-85D5-907A91A9CEDE/Documents/.kivy/logs/kivy_24-05-07_2.txt
[INFO   ] [Kivy        ] v2.3.0
[INFO   ] [Kivy        ] Installed at "/Users/jack/Library/Developer/CoreSimulator/Devices/99A60CC7-AFB9-457C-A0E2-BB253DD5790A/data/Containers/Bundle/Application/B7A39577-838D-4A52-8C3B-F6B545B497D9/grooveid.app/lib/python3.11/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.11.6 (main, Apr 30 2024, 15:13:06) [Clang 15.0.0 (clang-1500.3.9.4)]
[INFO   ] [Python      ] Interpreter at "/Users/jack/Library/Developer/CoreSimulator/Devices/99A60CC7-AFB9-457C-A0E2-BB253DD5790A/data/Containers/Bundle/Application/B7A39577-838D-4A52-8C3B-F6B545B497D9/grooveid.app/grooveid"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [Factory     ] 195 symbols loaded
[INFO   ] [Image       ] Providers: img_imageio, img_tex, img_sdl2 (img_dds, img_ffpyplayer, img_pil ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
You need UIApplicationSupportsIndirectInputEvents in your Info.plist for mouse support
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <gl>
[INFO   ] [GL          ] OpenGL version <b'OpenGL ES 2.0 APPLE-21.0.19'>
[INFO   ] [GL          ] OpenGL vendor <b'Apple Inc.'>
[INFO   ] [GL          ] OpenGL renderer <b'Apple Software Renderer'>
[INFO   ] [GL          ] OpenGL parsed version: 2, 0
[INFO   ] [GL          ] Shading version <b'OpenGL ES GLSL ES 1.00'>
[INFO   ] [GL          ] Texture max size <4096>
[INFO   ] [GL          ] Texture max units <8>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Loader      ] using a thread pool of 2 workers
Got dlopen error on Foundation: dlopen(/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 0x0001): tried: '/Users/jack/Library/Developer/Xcode/DerivedData/grooveid-aplpukfmxonywzfofpyklsdrazgx/Build/Products/Debug-iphonesimulator/Foundation.framework/Versions/Current/Foundation' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation' (no such file), '/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation' (no such file, not in dyld cache), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation' (no such file), '/Users/jack/Library/Developer/Xcode/DerivedData/grooveid-aplpukfmxonywzfofpyklsdrazgx/Build/Products/Debug-iphonesimulator/Foundation.framework/Versions/C/Foundation' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation' (no such file), '/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation' (no such file, not in dyld cache), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation' (no such file)
Got fallback dlopen error on Foundation: dlopen(/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 0x0001): tried: '/Users/jack/Library/Developer/Xcode/DerivedData/grooveid-aplpukfmxonywzfofpyklsdrazgx/Build/Products/Debug-iphonesimulator/Foundation.framework/Versions/Current/Foundation' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation' (no such file), '/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation' (no such file)
[INFO   ] [Clipboard   ] Provider: sdl2
 Traceback (most recent call last):
   File "/Users/jack/Documents/workshop/KivyBuilds/kivy-ios/grooveid-ios/YourApp/main.py", line 50, in <module>
   File "/Users/jack/Library/Developer/CoreSimulator/Devices/99A60CC7-AFB9-457C-A0E2-BB253DD5790A/data/Containers/Bundle/Application/B7A39577-838D-4A52-8C3B-F6B545B497D9/grooveid.app/lib/python311.zip/multiprocessing/pool.py", line 28, in <module>
   File "/Users/jack/Library/Developer/CoreSimulator/Devices/99A60CC7-AFB9-457C-A0E2-BB253DD5790A/data/Containers/Bundle/Application/B7A39577-838D-4A52-8C3B-F6B545B497D9/grooveid.app/lib/python311.zip/multiprocessing/util.py", line 17, in <module>
 ImportError: cannot import name '_args_from_interpreter_flags' from 'subprocess' (unknown location)
Application quit abnormally!
Leaving

Screenshots (Didn't think this was needed since it's just writing within the Logs part of Xcode, but I'm more than happy to share screenshots if it's of any help)

Additional context I checked and can't seem to find a subprocess.py or subprocess folder in any relating folders that the App uses. I ran into this error a while back, which I tried to fix by finding the subprocess.py file and pasting it into the folder. The error was removed briefly but returned not long after, once I fixed a few other problems.

Any Help is massively appreciated, thanks!

misl6 commented 6 months ago

Looks like you're using multiprocessing and therefore subprocess:

   File "/Users/jack/Documents/workshop/KivyBuilds/kivy-ios/grooveid-ios/YourApp/main.py", line 50, in <module>
   File "/Users/jack/Library/Developer/CoreSimulator/Devices/99A60CC7-AFB9-457C-A0E2-BB253DD5790A/data/Containers/Bundle/Application/B7A39577-838D-4A52-8C3B-F6B545B497D9/grooveid.app/lib/python311.zip/multiprocessing/pool.py", line 28, in <module>
   File "/Users/jack/Library/Developer/CoreSimulator/Devices/99A60CC7-AFB9-457C-A0E2-BB253DD5790A/data/Containers/Bundle/Application/B7A39577-838D-4A52-8C3B-F6B545B497D9/grooveid.app/lib/python311.zip/multiprocessing/util.py", line 17, in <module>
 ImportError: cannot import name '_args_from_interpreter_flags' from 'subprocess' (unknown location)

Both are not available (due to iOS limitations): https://github.com/kivy/kivy-ios/blob/master/FAQ.md#why-does-the-python-multiprocesssubprocess-module-not-work

Feel free to reach out to our support channels if you need some help to migrate your code to a supported pattern.

github-actions[bot] commented 6 months ago

đź‘‹ We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project. For troubleshooting advice and other frequently asked questions, consult the latest Kivy for iOS FAQ. Let us know if this comment was made in error, and we'll be happy to reopen the issue.