Closed EstevanBR closed 2 months ago
Hi Estevan! I've tried to use this repo for generating project on my M2 chip based mac and run into similar issues.
Is it possible to make LIBRARY_NAME
and EXECUTABLE_NAME
configurable? I mean use other values from "\(projectName)
", and "\(projectName)Game
"?
I've also already tried to replace .so dynamic libraries with .dylib, but still having issues with "Error loading GDExtension configuration file
".
- I get some errors when running make pack that it fails with code 1, need to investigate
I tried to tweak makefile pack section and found out that if I remove "$(GODOT) $(GODOT_PROJECT_FILE_PATH) --quit
", then .pck files are created successfully and resources can be reached. Also adding a "-
" sign helps too.
What is also interesting, running make open
does not produce any errors and Godot editor is loaded successfully without any issues. While running make run
or running executable target from Xcode it throws "Error loading GDExtension configuration file
" error.
Also I have a question about setting Godot 4.2 executable
path. Should it point to "/Applications/Godot.app
" or "/Applications/Godot.app/Contents/MacOS/Godot
"?
@Maxim-Lanskoy Hello, Maxim, thank you for trying to use my tool!
I'll try and resolve this issue soon. Afraid it's a big mess right now.
Is it possible to make LIBRARY_NAME and EXECUTABLE_NAME configurable? I mean use other values from "(projectName)", and "(projectName)Game"?
Ah, so you'd like to be able to name EXECUTABLE_NAME something other LIBRARY_NAME with Game
suffix? yes that should be easy to do.
Also I have a question about setting Godot 4.2 executable path. Should it point to "/Applications/Godot.app" or "/Applications/Godot.app/Contents/MacOS/Godot"?
The latter, here it is in my .env:
export GODOT=/Applications/Godot-4.2.2-stable.official.app/Contents/MacOS/Godot`
I tried to tweak makefile pack section and found out that if I remove "$(GODOT) $(GODOT_PROJECT_FILE_PATH) --quit", then .pck files are created successfully and resources can be reached. Also adding a "-" sign helps too.
Yes, this will work. However, if you edit a resource and don't reopen the project before exporting the .pck again, the resource will not be updated. Godot has to reimport the files, this is why I've added the line to open the Godot project and then immediately quit.
I also had to edit some of the generated files to get it to work on my M3 mac, here are some of my workarounds:
[configuration]
entry_symbol = "swift_entry_point"
compatibility_minimum = 4.2
[libraries]
macos.debug = "res://bin/libMyProject.dylib"
macos.release = "res://bin/libMyProject.dylib"
windows.debug.x86_32 = "res://bin/libMyProject.dylib"
windows.release.x86_32 = "res://bin/libMyProject.dylib"
windows.debug.x86_64 = "res://bin/libMyProject.dylib"
windows.release.x86_64 = "res://bin/libMyProject.dylib"
linux.debug.x86_64 = "res://bin/libMyProject.dylib"
linux.release.x86_64 = "res://bin/libMyProject.dylib"
linux.debug.arm64 = "res://bin/libMyProject.dylib"
linux.release.arm64 = "res://bin/libMyProject.dylib"
linux.debug.rv64 = "res://bin/libMyProject.dylib"
linux.release.rv64 = "res://bin/libMyProject.dylib"
android.debug.x86_64 = "res://bin/libMyProject.dylib"
android.release.x86_64 = "res://bin/libMyProject.dylib"
android.debug.arm64 = "res://bin/libMyProject.dylib"
android.release.arm64 = "res://bin/libMyProject.dylib"
Here is my Makefile
include .env
.PHONY: all
all: paths build deploy pack
.PHONY: paths
paths:
@echo "Path to Godot executable:\n\t$(GODOT)"
@echo "Godot bin/ path:\n\t$(GODOT_BIN_PATH)"
@echo "Build path:\n\t$(BUILD_PATH)"
@echo "Godot version:\n\t`$(GODOT) --version`"
@echo "Library name:\n\t$(LIBRARY_NAME)"
@echo "Executable name:\n\t$(EXECUTABLE_NAME)"
@echo "Godot project file path:\n\t$(GODOT_PROJECT_FILE_PATH)"
.PHONY: build
build:
mkdir -p $(BUILD_PATH)
swift build --product $(LIBRARY_NAME) --build-path $(BUILD_PATH)
swift build --product $(EXECUTABLE_NAME) --build-path $(BUILD_PATH)
.PHONY: deploy
deploy:
rm -rf $(GODOT_BIN_PATH)
mkdir -p $(GODOT_BIN_PATH)
cp $(BUILD_PATH)/debug/lib$(LIBRARY_NAME).dylib $(GODOT_BIN_PATH)
cp $(BUILD_PATH)/debug/libSwiftGodot.dylib $(GODOT_BIN_PATH)
.PHONY: run
run:
swift run $(EXECUTABLE_NAME) --build-path $(BUILD_PATH)
.PHONY: open
open:
$(GODOT) $(GODOT_PROJECT_FILE_PATH)
.PHONY: pack
pack:
@echo "Going to open Godot to ensure all resources are imported."
$(GODOT) $(GODOT_PROJECT_FILE_PATH) --quit
@echo "Exporting the .pck file"
$(GODOT) --headless --path $(GODOT_PROJECT_DIRECTORY) --export-pack Packer ../Sources/$(LIBRARY_NAME)Game/Resources/$(LIBRARY_NAME).pck
You'll also want to make sure libSwiftGodot.dylib is in the res://bin/
folder of the godot project:
├── Sources/
│ ├── MyProject/
│ └── MyProjectGame/
└── godot/
└── bin/
├── libMyProject.dylib
└── libSwiftGodot.dylib
What is also interesting, running make open does not produce any errors and Godot editor is loaded successfully without any issues. While running make run or running executable target from Xcode it throws "Error loading GDExtension configuration file" error.
I think this is because the export is excluding the .gdextension
file, when running the game via SwiftGodotKit, the executable target will register the types, and it will load the library. I believe if the .gdextension were included, then types would be imported twice, and there would be two instances of the library.
Everything should operate fine, I believe you can ignore the warning but let me know if you experience otherwise!
@Maxim-Lanskoy Ok! let me know if this resolves the issue for you. I'll push a new tag as well.
So yeah, make
commands are now passing correctly. Renaming executable also works like a charm. But I'm still having issues when running make run
or launch executable target in Xcode.
ERROR: Error loading GDExtension configuration file: res://Name.gdextension ERROR: Failed loading resource: res://Name.gdextension. Make sure resources have been imported by opening the project in the editor at least once. ERROR: Error loading extension: res://Name.gdextension
Removing .gdextension
file from Packer excludes helps, but then types are imported twice, just as you've said. I have another project, where I've made setup by following tutorial from SwiftGodot documentation site and do not facing this issue there. But I can not find differences in setup which are causing this.
@Maxim-Lanskoy I created an issue #7 lets continue the discussion there.
I tried using the tool on my MBP with an M3 Pro.
On Mac: .dylib = dynamic lib .a = static lib
On my Ubuntu machine: .so = dynamic lib .a = static lib