Overview: gdextension fails to load when running an exported app on macOS through finder or using the open command.
Situation
- Using Godot version
4.4.stable.official.4c311cbee
- I have a project with a gdextension written in Swift using SwiftGodot → library is
libPoieticGodot.dylib
- The library has a dependency
libSwiftGodot.dylib
- The extension is in
bin/ directory and the structure looks as follows (note the main .dylib and its dependency).
bin
├── Poietic.gdextension
├── Poietic.gdextension.uid
├── libPoieticGodot.dylib
└── libSwiftGodot.dylib
The .gdextension file is:
[configuration]
entry_symbol = "swift_entry_point"
compatibility_minimum = 4.2
[libraries]
# macos.debug = "res://bin/libPoieticGodot.dylib"
macos.debug.arm64 = "res://bin/libPoieticGodot.dylib"
macos.release.arm64 = "res://bin/libPoieticGodot.dylib"
linux.debug.x86_64 = "res://bin/libPoieticGodot.so"
linux.release.x86_64 = "res://bin/libPoieticGodot.so"
linux.debug.arm64 = "res://bin/libPoieticGodot.so"
linux.release.arm64 = "res://bin/libPoieticGodot.so"
linux.debug.rv64 = "res://bin/libPoieticGodot.so"
linux.release.rv64 = "res://bin/libPoieticGodot.so"
[dependencies]
macos.debug.arm64 = {
"res://bin/libPoieticGodot.dylib": "Contents/Frameworks",
"res://bin/libSwiftGodot.dylib": "Contents/Frameworks"
}
macos.release.arm64 = {
"res://bin/libPoieticGodot.dylib": "Contents/Frameworks",
"res://bin/libSwiftGodot.dylib": "Contents/Frameworks"
}
- Both libraries are copied correctly inside of the .app bundle in the dmg file into
Contents/Frameworks:
% tree /Volumes/Poietic\ Playground/Poietic\ Playground.app
/Volumes/Poietic Playground/Poietic Playground.app
└── Contents
├── Frameworks
│ ├── libPoieticGodot.dylib
│ └── libSwiftGodot.dylib
├── Info.plist
├── MacOS
│ └── Poietic Playground
├── PkgInfo
└── Resources
├── Poietic Playground.pck
├── PrivacyInfo.xcprivacy
└── icon.icns
Problem
I export a .dmg file with an app Poietic Plaground.app. When I run the app from the Finder or using open "path/to/Poietic Playground.app it does not load the extension. I see the following in console logs:
Poietic Playground[37654]: ERROR: Can't open dynamic library: bin/libPoieticGodot.dylib. Error: dlopen(bin/libPoieticGodot.dylib, 0x0002): tried: 'bin/libPoieticGodot.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSbin/libPoieticGodot.dylib' (no such file), '/Volumes/Poietic Playground/Poietic Playground.app/Contents/Frameworks/bin/libPoieticGodot.dylib' (no such file), '/Volumes/Poietic Playground/Poietic Playground.app/Contents/MacOS/bin/libPoieticGodot.dylib' (no such file), '/Volumes/Poietic Playground/Poietic Playground.app/Contents/Frameworks/bin/libPoieticGodot.dylib' (no such file), '/Volumes/Poietic Playground/Poietic Playground.app/Contents/MacOS/bin/libPoieticGodot.dylib' (no such file), '/usr/lib/bin/libPoieticGodot.dylib' (no such file, not in dyld cache), 'bin/libPoieticGodot.dylib' (no such file), '/bin/libPoieticGodot.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/bin/libPoieticGodot.dylib' (no such file), '/bin/libPoieticGodot.dylib' (no such file).
When I try to run the executable directly as /Volumes/Poietic\ Playground/Poietic\ Playground.app/Contents/MacOS/Poietic\ Playground it works, loads the extension properly.
What I have to do or check to make it work?
Cheers