EditorExportPlatformMacOS in Godot – Complete Guide

Welcome to this comprehensive guide on using **EditorExportPlatformMacOS** in Godot 4. If you’re a Godot developer aiming to polish and share your game with Mac users, you’re in the right place! This class is your gateway to preparing a game for export to macOS, handling everything from setting up icons and bundle identifiers to managing privacy permissions and code-signing your application. Whether you are a beginner eager to distribute your first creation or an experienced coder looking to streamline your game’s deployment process, you’ll find valuable insights in this tutorial series.

What is EditorExportPlatformMacOS?

The **EditorExportPlatformMacOS** is a class in Godot 4 dedicated to configuring and optimizing export settings specifically for macOS. It’s a cornerstone for developers looking to properly package their games for Apple’s desktop environment.

What is it for?

This class serves as an interface within the Godot engine, allowing you to assign essential properties and metadata to your game’s executable package. It encompasses a variety of configurations, such as application information, permissions, codesign guidelines, and sandbox compliance – all crucial for a seamless deployment on macOS.

Why Should I Learn It?

Understanding **EditorExportPlatformMacOS** is beneficial for a few key reasons:

– **Distribution Readiness**: By mastering this class, you ensure that your game meets the technical standards required for macOS distribution, be it through the App Store or independently.
– **Platform-Specific Features**: Learning about these settings enables you to utilize macOS features effectively, such as high-resolution displays or Apple-specific hardware.
– **Security Compliance**: In today’s digital landscape, code-signing and sandboxing are essential for user trust and safety. Knowledge of these features helps you build a secure experience for your players.

Let’s dive into the coding tutorial and start bringing your Godot projects to the macOS platform with ease and confidence.

CTA Small Image

Setting Up the Export Preset

Before we get into the specifics of **EditorExportPlatformMacOS**, it’s important to set up an export preset for macOS within your Godot project. An export preset defines all the parameters you’ll use to export your game.

First, let’s create a new export preset for macOS:

var export_preset = EditorExportPreset.new()
export_preset.set_platform("Mac OSX")
export_preset.set_name("Mac Export Preset")

Next, you’ll need to configure the basics such as the application’s unique identifier and version:

export_preset.set("application/config/name", "YourGameName")
export_preset.set("application/config/bundle_identifier", "com.yourcompany.yourgame")
export_preset.set("application/config/version", "1.0.0")

This snippet sets your game’s name, bundle identifier, and version number within the export preset.

Customizing the Application Icon

Icons are critical for game recognition. You’ll want to define the icon for your macOS export. The following code sets the path to your game’s icon:

export_preset.set("application/config/icon", "res://path/to/your_icon.png")

Godot supports the macOS `.icns` format, so ensure you’ve formatted your icon appropriately.

Enabling Code Signing and Sandboxing

Code signing is vital for app security and sandboxing helps confine your app’s permissions to safeguard user data. Here’s how to enable these settings:

export_preset.set("application/config/codesign/enable", true)
export_preset.set("application/config/codesign/identity", "Mac Developer: Your Name (YOURKEY)")
export_preset.set("application/config/entitlements/sandbox", true)

Make sure to replace `”Your Name (YOURKEY)”` with your own developer identity provided by Apple.

Configuring Privacy Permissions

macOS requires explicit permission settings for accessing user data like contacts or the camera. You manage this through the `info_plist` property:

export_preset.set("application/config/info_plist", "res://path/to/your_info_plist.plist")

In your `plist` file, you might specify:

<string>This game requires access to the camera to update your avatar.</string>

This code informs users why your game requests camera access.

Handling High-Resolution Retina Displays

To ensure your game looks sharp on all screens, you’ll want to support high-resolution displays. Here’s how to handle Retina displays:

export_preset.set("display/window/allow_hidpi", true)

This setting allows your game to run in high-DPI mode to support Retina displays.

Exporting Your Game

After all configurations are done, it’s time to export your game. You might automate the export process with a single function:

func export_game():
    var exporter = EditorExport.get_singleton()
    var err = exporter.export_project(export_preset, "path/to/export/mygame.zip", false)
    if err != OK:
        push_error("Failed to export project: " + str(err))

This function exports your game to the specified path.

We’ve covered the basics of setting up and configuring your macOS export in Godot 4. Up next, we’ll advance into some more detailed aspects of the **EditorExportPlatformMacOS** settings. Stay tuned!Moving forward, we’ll delve into the specifics of how **EditorExportPlatformMacOS** can fine-tune your export settings to further polish your macOS game package.

One common necessity is to manage the architecture of the exported binary. In macOS, this could mean choosing to support Intel (x86_64) or Apple Silicon (ARM). The following code snippet sets the architecture to Universal, which includes both:

export_preset.set("application/macos/arch", "universal")

This ensures your game can run on the widest range of macOS devices.

Localization is another important factor. Godot supports exporting your game with multiple languages, and you can specify the locales your game will support:

export_preset.set("application/config/locales", PoolStringArray(["en", "es", "fr", "de"]))

This configures the game to include English, Spanish, French, and German language support.

Handling game data is an important aspect of game development. If your game needs to access files after export, you might want to programmatically add export rules. You can do this by setting the export filters:

export_preset.set("resources/export_mode", 0) # Export all resources in the project
export_preset.set("resources/filter", "*.png,*.json")
export_preset.set("resources/exclude_filter", "secrets.json,*.pdb")

The first line sets the mode to export all resources. The second line then includes only PNG and JSON files in the export, while the third line ensures that certain files, such as a sensitive `secrets.json` or unnecessary `.pdb` files, are excluded.

You might also want to consider setting the application category for macOS:

export_preset.set("application/macos/category", "public.app-category.games")

This categorizes your app as a game in the macOS ecosystem, making it easier for users to find your product in the appropriate category.

Custom scripts sometimes need to be run post-export. These could handle additional packaging steps or cleanup. You can add a post-export script via the following method:

export_preset.set("application/config/post_export_script", "res://path/to/post_export_script.gd")

Ensure that the script at `res://path/to/post_export_script.gd` is equipped to execute the required post-export operations.

Lastly, if you plan to notarize your app for distribution outside of the Mac App Store, you’ll need to handle notarization scripts as well:

export_preset.set("application/macos/notarize_script", "res://path/to/notarize_script.gd")

This sets a path to a script that can facilitate the notarization process, which is crucial for verifying your app’s security and integrity.

By understanding these advanced features of the **EditorExportPlatformMacOS** and including them in your export process, you can ensure that your game is not only prepared for macOS users but also benefits from the platform’s unique capabilities and adheres to its security standards.Adding to our tutorial on **EditorExportPlatformMacOS**, let’s explore further customization options that you can leverage for a highly tailored macOS build. Godot offers a robust toolset to configure your game’s appearance and behavior upon launch, manage external files, and ensure a seamless user experience.

When dealing with custom icon files for different sizes, you might want to specify each icon size individually for better control over appearance across devices:

export_preset.set("application/macos/icon_128x128", "res://icons/app_icon_128.png")
export_preset.set("application/macos/icon_256x256", "res://icons/app_icon_256.png")
export_preset.set("application/macos/icon_512x512", "res://icons/app_icon_512.png")
export_preset.set("application/macos/icon_1024x1024", "res://icons/app_icon_1024.png")

By providing specific icons for different sizes, you can ensure crisp and detailed icons are used for each resolution.

For handling project files, you might need to include files or directories from outside your project. Here’s how you can add external files to your export:

export_preset.add_resource_file("res://external_files/my_additional_file.txt", "my_additional_file.txt", false)

This code will include the file `my_additional_file.txt` located in your Godot project’s `external_files` directory directly into the root of the exported game package.

As your game development progresses, you may find yourself with several deployment configurations. For instance, you may have different game behaviors or features for development and production versions. You can manage this by setting up custom features for your export:

export_preset.set("application/config/custom_features", "production")

This sets a custom feature named `production`, which you can then check in your game’s script using `OS.has_feature(“production”)` to tailor game behavior accordingly.

Sometimes, you might want to enable a console window, which can be useful for debugging purposes. To include a console window alongside your game, add the following setting:

export_preset.set("application/run/with_console", true)

Now, when the exported game runs on macOS, a console window will also open, displaying stdout and stderr output, which can be invaluable for debugging.

If you’re working with multiplayer games or network features, you may need to adjust app transport security settings. Godot enables you to specify these settings for macOS export:

export_preset.set("application/macos/ats/allow_http", true)
export_preset.set("application/macos/ats/exceptions", [dict({"domain":"example.com", "include_subdomains":true, "allow_http": false})])

The first line allows non-secured HTTP connections (not recommended for production), while the second line sets specific rules for `example.com`, disallowing HTTP and allowing subdomains.

Finally, although macOS applications are often run from their bundled form, some applications may need to have executables installed into the system. Here’s how to specify whether your macOS application is bundled or not:

export_preset.set("application/macos/install", true)

This configuration tells Godot to prepare the application in a way that’s suitable for system-wide installation.

These customizations offered by the **EditorExportPlatformMacOS** class empower you further in packaging and optimizing your applications for macOS ecosystems. Tailoring your build settings ensures that the deployment of your Godot application on macOS aligns with your project’s requirements and delivers the best user experience possible.

Where to Go Next?

As you continue your journey in game development with Godot, it’s clear that there’s always more to discover and master. Whether you’re fine-tuning your skills or branching out into new areas, consistent learning is key to staying ahead in this dynamic field. We at Zenva encourage you to keep building, experimenting, and expanding your knowledge.

To further guide your growth, consider exploring our Godot Game Development Mini-Degree. This comprehensive course collection is designed to take you from the basics to creating full-fledged games with the Godot 4 engine. Dive into a variety of game development topics and hone your skills across a range of projects that will form a standout portfolio.

For those seeking an even broader look at what Godot has to offer, our extensive catalog of Godot courses covers everything from essential techniques to advanced features. No matter where you are in your game development journey, Zenva is here to support your learning and help you achieve your dreams of creating amazing games.


Embarking on the adventure of game development using Godot 4, and in particular, tapping into the power of EditorExportPlatformMacOS, marks a significant step in your journey as a game creator. With your newfound knowledge, you’re now equipped to meticulously sculpt your game’s macOS exportation process, ensuring it shines in the marketplace and provides Mac users with the best gaming experience possible.

Remember, the path to mastering game development is continuous and filled with exciting challenges and learning opportunities. Embrace the process, and never hesitate to dive deeper. We at Zenva are thrilled to be part of your journey and look forward to seeing the amazing games you’ll create. Let the adventure continue by enhancing your expertise through our Godot Game Development Mini-Degree, and turn your game ideas into reality!

Python Blog Image

FINAL DAYS: Unlock coding courses in Unity, Godot, Unreal, Python and more.