KivyMD Xcode build error - ImportError: dynamic module does not define module export function (PyInit__imaging)

I am building a Python KivyMD app with MAC Xcode, the code was able to run, but the app didn't load on the iphonesimulator. The log is below. MAC - Big Sur Xcode - 13.1 Python - 3.8

Got fallback dlopen error on Foundation: dlopen(/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 0x0001): tried: '/Users/xxxxxxxx/Library/Developer/Xcode/DerivedData/vocgo-fywrtcoideyfwrepueohqjxjodsj/Build/Products/Debug-iphonesimulator/Foundation.framework/Versions/Current/Foundation' (no such file), '/Users/xxxxxxxx/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.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), '/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation' (no such file)
 Traceback (most recent call last):
   File "/Users/xxxxxxxx/vocgo-ios/YourApp/main.py", line 7, in <module>
   File "/Users/xxxxxxxx/Library/Developer/CoreSimulator/Devices/5430FAEF-F9A3-46F7-B9D3-602717473C51/data/Containers/Bundle/Application/9CCC1550-5D8A-4DF7-8186-C052833273B0/vocgo.app/lib/python3.8/site-packages/kivymd/uix/__init__.py", line 8, in <module>
     from kivymd.uix.behaviors import SpecificBackgroundColorBehavior
   File "/Users/xxxxxxxx/Library/Developer/CoreSimulator/Devices/5430FAEF-F9A3-46F7-B9D3-602717473C51/data/Containers/Bundle/Application/9CCC1550-5D8A-4DF7-8186-C052833273B0/vocgo.app/lib/python3.8/site-packages/kivymd/uix/behaviors/__init__.py", line 10, in <module>
     from .backgroundcolor_behavior import (
   File "/Users/xxxxxxxx/Library/Developer/CoreSimulator/Devices/5430FAEF-F9A3-46F7-B9D3-602717473C51/data/Containers/Bundle/Application/9CCC1550-5D8A-4DF7-8186-C052833273B0/vocgo.app/lib/python3.8/site-packages/kivymd/uix/behaviors/backgroundcolor_behavior.py", line 25, in <module>
     from .elevation import CommonElevationBehavior
   File "/Users/xxxxxxxx/Library/Developer/CoreSimulator/Devices/5430FAEF-F9A3-46F7-B9D3-602717473C51/data/Containers/Bundle/Application/9CCC1550-5D8A-4DF7-8186-C052833273B0/vocgo.app/lib/python3.8/site-packages/kivymd/uix/behaviors/elevation.py", line 364, in <module>
     from PIL import Image, ImageDraw, ImageFilter
   File "<frozen zipimport>", line 259, in load_module
   File "/Users/xxxxxxxx/Library/Developer/CoreSimulator/Devices/5430FAEF-F9A3-46F7-B9D3-602717473C51/data/Containers/Bundle/Application/9CCC1550-5D8A-4DF7-8186-C052833273B0/vocgo.app/lib/python3.8/site-packages/Pillow-6.1.0-py3.8-macosx-11.6-x86_64.egg/PIL/Image.py", line 95, in <module>
   File "<frozen zipimport>", line 259, in load_module
   File "/Users/xxxxxxxx/Library/Developer/CoreSimulator/Devices/5430FAEF-F9A3-46F7-B9D3-602717473C51/data/Containers/Bundle/Application/9CCC1550-5D8A-4DF7-8186-C052833273B0/vocgo.app/lib/python3.8/site-packages/Pillow-6.1.0-py3.8-macosx-11.6-x86_64.egg/PIL/_imaging.py", line 7, in <module>
   File "/Users/xxxxxxxx/Library/Developer/CoreSimulator/Devices/5430FAEF-F9A3-46F7-B9D3-602717473C51/data/Containers/Bundle/Application/9CCC1550-5D8A-4DF7-8186-C052833273B0/vocgo.app/lib/python3.8/site-packages/Pillow-6.1.0-py3.8-macosx-11.6-x86_64.egg/PIL/_imaging.py", line 6, in __bootstrap__
   File "/Users/xxxxxxxx/dist/root/python3/lib/python3.8/imp.py", line 342, in load_dynamic
 ImportError: dynamic module does not define module export function (PyInit__imaging)
2021-11-03 21:36:14.027017+1100 vocgo[9686:99184] Application quit abnormally!

I heard KivyMD still has many issues when built with Xcode. I was not able to find valuable answers about this error. I felt that I have more than one problem. Please shed some light. Thanks heaps.

This is the official answer from Github Kivy-ios group. The trick is to clone the kivy-ios.git

git clone https://github.com/kivy/kivy-ios.git

@Jesscarlett this is due to #606. The kivy-ios version available on PyPI is 1.2.1, which doesn't include that patch, unlike the current master version which includes it. I'm closing this issue, cause should be fixed via #606. But feel free to reopen if needed.

KivyMD Xcode build error - ImportError: dynamic module does not define module export function (PyInit__imaging)
 
 
Q