Got dlopen error on Foundation: (...): image not found

Hi!

I am new to Xcode and iOS apps, but I managed to build and test my app in the iPhone 8 simulator.
I am using my Apple ID as 'developer team'. And I have approved that on my iPhone.
When I deploy my app on my iPhone 5s (running iOS 12.5.1) it builds without problems, but when I try to run it by pressing the icon, the debug log shows this error:

Got dlopen error on Foundation: dlopen(/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 1): image not found
Got fallback dlopen error on Foundation: dlopen(/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 1): image not found
2021-02-28 23:09:59.023510+0100 geo-esp-training[457:91731] XPC connection interrupted

Can any one please tell me what's the problem?

I can add that I am using a MacBook Pro (Mid 2012) running MacOS Catalina 10.15.7 and Xcode Version 12.4.
The app is actually a Python app using the Kivy interface framework.

Thank you!
Henrik R.

This is the whole log output from Xcode:

2021-02-28 23:09:53.270436+0100 geo-esp-training[457:91714] [DYMTLInitPlatform] platform initialization successful
2021-02-28 23:09:53.757600+0100 geo-esp-training[457:91293] [framework] CUIThemeStore: No theme registered with id=0
2021-02-28 23:09:54.007960+0100 geo-esp-training[457:91293] Available orientation: KIVY_ORIENTATION=LandscapeLeft LandscapeRight Portrait PortraitUpsideDown
2021-02-28 23:09:54.008907+0100 geo-esp-training[457:91293] Initializing python
2021-02-28 23:09:54.536792+0100 geo-esp-training[457:91293] Running main.py: /var/containers/Bundle/Application/2C4A20A0-A9AA-4AC7-B8A7-1A6322B17DD9/geo-esp-training.app/YourApp/main.pyc
[INFO ] [Kivy ] v2.1.0.dev0
[INFO ] [Kivy ] Installed at "/var/containers/Bundle/Application/2C4A20A0-A9AA-4AC7-B8A7-1A6322B17DD9/geo-esp-training.app/lib/python3.8/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.8.2 (default, Feb 26 2021, 22:00:00)
[Clang 12.0.0 (clang-1200.0.32.29)]
[INFO ] [Python ] Interpreter at "/var/containers/Bundle/Application/2C4A20A0-A9AA-4AC7-B8A7-1A6322B17DD9/geo-esp-training.app/geo-esp-training"
[INFO ] [Factory ] 186 symbols loaded
[INFO ] [Image ] Providers: img_imageio, img_tex (img_dds, img_sdl2, img_ffpyplayer, img_pil ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Video ] Provider: null(['video_ffmpeg', 'video_ffpyplayer'] ignored)
Got dlopen error on Foundation: dlopen(/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 1): image not found
Got fallback dlopen error on Foundation: dlopen(/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 1): image not found
2021-02-28 23:09:59.023510+0100 geo-esp-training[457:91731] XPC connection interrupted
[WARNING] [Factory ] Ignored class "ScalableLabel" re-declaration. Current - module: None, cls: <class 'sharebox_ubuntu.ScalableLabel'>, baseclass: None, filename: None. Ignored - module: None, cls: None, baseclass: Label, filename: /private/var/containers/Bundle/Application/2C4A20A0-A9AA-4AC7-B8A7-1A6322B17DD9/geo-esp-training.app/YourApp/MyTabbedPanel.kv.
Traceback (most recent call last):
File "/Users/henrik/geo-esp-training-ios/YourApp/main.py", line 252, in <module>
File "/Users/henrik/geo-esp-training-ios/YourApp/main.py", line 180, in __init__
PermissionError: [Errno 1] Operation not permitted: 'geo-esp-train.cfg'
2021-02-28 23:09:59.085006+0100 geo-esp-training[457:91293] Application quit abnormally!
2021-02-28 23:09:59.294003+0100 geo-esp-training[457:91293] Leaving
Answered by HenrikRo in 666439022
Solved!

It turns out that the fact that Xcode and iOS and dlopen could not find a 'Foundation.framework' 'image' was not the real problem.
Python gave this error log:

Traceback (most recent call last):
File "/Users/henrik/geo-esp-training-ios/YourApp/main.py", line 252, in <module>
File "/Users/henrik/geo-esp-training-ios/YourApp/main.py", line 180, in __init__
PermissionError: [Errno 1] Operation not permitted: 'geo-esp-train.cfg'
2021-03-10 14:18:50.105679+0100 geo-esp-training[448:20514] Application quit abnormally!
2021-03-10 14:18:50.161136+0100 geo-esp-training[448:20514] Leaving

The solution was to actively specify in Python-Kivy that my data files have to be written to the app user data directory. This is how to do that:

Code Block
class RootLayout(FloatLayout): # This is the root widget of my Kivy app
def __init__(self, kwargs):
super().__init__(kwargs)
app = App.get_running_app()
print("app.directory = ", app.directory)
print("app.user_data_dir = ", app.user_data_dir)
global configfilename, user_data_dir_path
configfilename = os.path.join(app.user_data_dir, 'geo-esp-train.cfg')
user_data_dir_path = app.user_data_dir # Used for other data files.


I have now run my Kivy app on an iPhone 5s simulator in Xcode. That gives a slightly different error, but the app DOES run without any real problems. So the question is: How serious are these 'dlopen' errors? Here comes the slightly different error from the simulator:

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
Got fallback dlopen error on Foundation: dlopen(/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 1): image not found

Note that I DON'T get this error:

2021-02-28 23:09:59.023510+0100 geo-esp-training[457:91731] XPC connection interrupted

Note:
My Mac has 29 'Foundation.framework' folders and a total of 672
'*Foundation.framework' folders... So how am I to know which folder to
point to instead of the one where the 'image' is not found?
I still haven't found a solution nor received any answered on the forums where I have posted my 'dlopen' problem. Someone asked me to try a newer iPhone, so I have bought an iPhone 7.
My Python-Kivy app runs without any real problems on the iPhone 7 simulator (in Xcode). But the physical iPhone 7 gives the same error as the iPhone 5s. Here is the relevant part of the log output from Xcode:

Got dlopen error on Foundation:
dlopen(/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 1): image not found
Got fallback dlopen error on Foundation:
dlopen(/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation, 1): image not found

Traceback (most recent call last):
File "/Users/henrik/geo-esp-training-ios/YourApp/main.py", line 252, in <module>
File "/Users/henrik/geo-esp-training-ios/YourApp/main.py", line 180, in init
PermissionError: [Errno 1] Operation not permitted: 'geo-esp-train.cfg'
2021-03-10 14:18:50.105679+0100 geo-esp-training[448:20514] Application quit abnormally!
2021-03-10 14:18:50.161136+0100 geo-esp-training[448:20514] Leaving

Please help! It's very important that I get this app to run on iOS!
Accepted Answer
Solved!

It turns out that the fact that Xcode and iOS and dlopen could not find a 'Foundation.framework' 'image' was not the real problem.
Python gave this error log:

Traceback (most recent call last):
File "/Users/henrik/geo-esp-training-ios/YourApp/main.py", line 252, in <module>
File "/Users/henrik/geo-esp-training-ios/YourApp/main.py", line 180, in __init__
PermissionError: [Errno 1] Operation not permitted: 'geo-esp-train.cfg'
2021-03-10 14:18:50.105679+0100 geo-esp-training[448:20514] Application quit abnormally!
2021-03-10 14:18:50.161136+0100 geo-esp-training[448:20514] Leaving

The solution was to actively specify in Python-Kivy that my data files have to be written to the app user data directory. This is how to do that:

Code Block
class RootLayout(FloatLayout): # This is the root widget of my Kivy app
def __init__(self, kwargs):
super().__init__(kwargs)
app = App.get_running_app()
print("app.directory = ", app.directory)
print("app.user_data_dir = ", app.user_data_dir)
global configfilename, user_data_dir_path
configfilename = os.path.join(app.user_data_dir, 'geo-esp-train.cfg')
user_data_dir_path = app.user_data_dir # Used for other data files.


Got dlopen error on Foundation: (...): image not found
 
 
Q