Exporting builds from Godot
Adding flags to exported builds
Section titled Adding flags to exported buildsI didn’t look into this too much, but what I did want is a way to determine if I was using a debug build, and that’s easy (reference): OS.has_feature("debug")
. When exporting, just make sure not to export a debug build, that way you can hide all of your “cheats” from the player.
Installing export templates
Section titled Installing export templatesThis needs to be done before any kind of export:
- Make sure you’ve downloaded Godot export templates from Editor → Manage Export Templates…:
- Make sure to install export templates (reference)
- All you need to do is:
- Set the export path (e.g.
./output.app
) - Fill out the bundle identifier (e.g.
com.example.game
) - If you’re not going to sign/notarize the app, then you should also enable Codesign → Entitlements → Disable Library Validation (it says to enable that option if you’re using ad-hoc signing, which should be the case, and you can verify that by reading the yellow warning text at the bottom of the export window).
- Click “Export All…”
- Set the export path (e.g.
- To run it, just do
open ./output.app
on the command line
Exporting Windows builds using a Mac
Section titled Exporting Windows builds using a MacIf you get that warning about needing rcedit
, you can just uncheck Application → Modify Resources, which means you won’t have a custom icon on Windows. If you do want a custom icon, then install rcedit
(and apparently WINE) following these instructions.
Web export
Section titled Web exportNote that as of 02/14/2024, you cannot do a web export from the .NET version of Godot, so make sure you open the non-Mono version; it says so right in the export dialog:
How to export
Section titled How to export- Make sure to install export templates (reference)
- Set the export path (e.g.
./out/index.html
)- Note: the
out
folder needs to exist for this to work - It’s a good idea to make an intermediate folder like
html
orout
since you’ll get more files than just the HTML file.
- Note: the
- Click “Export Project…” or do it through the command line
Hosting the web export
Section titled Hosting the web exportWith any means of hosting on the web, you may eventually see an error like this:
This means that the headers haven’t been set correctly by the web server. Sub-sections below talk about how to fix this.
Hosting locally
Section titled Hosting locally- Note: regardless of how you do this, you’ll need to do a new web export every time you want to update the game for people playing it. Also, you probably need to restart the server unless you only made client-side changes.
- The easiest way to do this is to use the Python script that they link from this page (here’s a direct link to the Python script, but maybe this’ll change eventually).
- The concrete steps are very simple:
- Download that page as
host.py
- Run
python3 host.py -r path_to_the_folder_containing_your_html_file
- Download that page as
- If you don’t do this and instead try to host with something like
http-server .
, you’ll get an error like this:
- The concrete steps are very simple:
- If you want to easily share this with people without having to upload this anywhere, just use Cloudflare Tunnels.
- When setting up the tunnel, you can choose “HTTP” and Cloudflare will automatically set up a certificate for you so that it works over HTTPS, which is apparently required by Godot for the secure-context stuff.
Hosting on a shared web host
Section titled Hosting on a shared web hostIf the host is based on Apache (e.g. it can be LiteSpeed Web Server), then it supports .htaccess
files, which means you can upload an .htaccess
file alongside your .html
file that looks like this:
Hosting on itch.io
Section titled Hosting on itch.ioThis should be straightforward. There’s some additional context around the header stuff here. I hosted a game on Itch a while ago, so I didn’t think there was much to write notes about this time around.
Troubleshooting
Section titled TroubleshootingExported game crashes on macOS
Section titled Exported game crashes on macOSInstead of doing open YourGame.app
, do cd YourGame.app/Contents/MacOS
→ ./YourGame
. That should show errors that won’t show when you use open
.
In my specific case, I saw ERROR: Can't load dependency: res://Src/SceneScripts/Main.cs.
, which seemed could have been a Godot issue but turned out to be my issue 🤦♂️.