Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Improvement

- Show export warning when iOS minimum version is too low for Sentry ([#628](https://github.com/getsentry/sentry-godot/pull/628))

### Fixes

- Fix iOS XCFramework plist reporting minimum version 12.0 instead of 15.0 ([#627](https://github.com/getsentry/sentry-godot/pull/627))
Expand Down
7 changes: 4 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ try:
except:
pass

version_header_content = """/* DO NOT EDIT - generated by SConstruct */
version_header_content = f"""/* DO NOT EDIT - generated by SConstruct */
#pragma once

#define SENTRY_GODOT_SDK_VERSION \"{version}+{git_sha}\"
""".format(version=VERSION, git_sha=git_sha)
#define SENTRY_GODOT_SDK_VERSION \"{VERSION}+{git_sha}\"
#define SENTRY_IOS_MIN_VERSION {IOS_MIN_VERSION}
"""

if not os.path.exists("src/gen/"):
os.mkdir("src/gen/")
Expand Down
33 changes: 33 additions & 0 deletions src/editor/export_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

#include <godot_cpp/classes/editor_export_platform.hpp>
#include <godot_cpp/variant/variant.hpp>

using namespace godot;

namespace sentry::editor {

// Creates a dictionary with a fake export check option for Sentry export plugins.
// This is needed because Godot's export dialog only shows bottom-bar warnings for
// plugin-owned options, so a fake option allows us to display warnings for
// Godot Engine-owned export options through that code path.
// Option is hidden from view, so users don't actually see it in the UI.
inline Dictionary make_hidden_export_check_option() {
Dictionary option;
option["option"] = Dictionary(PropertyInfo(
Variant::BOOL,
"sentry/_export_check",
PROPERTY_HINT_NONE,
String(),
PROPERTY_USAGE_NONE));
option["default_value"] = true;
return option;
}

// Checks if this option is either the builtin one we care about or our hidden sentry option.
// See make_hidden_export_check_option().
inline bool is_builtin_option_or_hidden_export_option(const String &p_option, const String &p_builtin_option) {
return p_option == p_builtin_option || p_option == "sentry/_export_check";
}

} //namespace sentry::editor
18 changes: 6 additions & 12 deletions src/editor/sentry_editor_export_plugin_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

#ifdef TOOLS_ENABLED

#include "export_utils.h"
#include <godot_cpp/classes/editor_export_platform.hpp>

using namespace sentry::editor;

String SentryEditorExportPluginAndroid::_get_name() const {
return "SentryAndroidExportPlugin";
}
Expand All @@ -28,23 +31,14 @@ PackedStringArray SentryEditorExportPluginAndroid::_get_android_dependencies(con

TypedArray<Dictionary> SentryEditorExportPluginAndroid::_get_export_options(const Ref<EditorExportPlatform> &p_platform) const {
TypedArray<Dictionary> options;
Dictionary option;
// HACK: Adding a hidden option so we can show a warning at the bottom of the export dialog.
option["option"] = Dictionary(PropertyInfo(
Variant::BOOL,
"sentry/_export_check",
PROPERTY_HINT_NONE,
String(),
PROPERTY_USAGE_NONE));
option["default_value"] = true;
options.push_back(option);
options.push_back(make_hidden_export_check_option());
return options;
}

String SentryEditorExportPluginAndroid::_get_export_option_warning(const Ref<EditorExportPlatform> &p_platform, const String &p_option) const {
// HACK: Also check "sentry/_export_check" so the warning appears at the bottom of the export dialog.
// Godot shows bottom-bar warnings through a separate code path that only checks plugin-owned options.
if ((p_option == "gradle_build/use_gradle_build" || p_option == "sentry/_export_check") &&
// HACK: Godot shows bottom-bar warnings through a separate code path that only checks plugin-owned options.
if (is_builtin_option_or_hidden_export_option(p_option, "gradle_build/use_gradle_build") &&
get_option("gradle_build/use_gradle_build") == Variant(false)) {
return "Sentry requires \"Use Gradle Build\" to be enabled for Android exports.";
}
Expand Down
44 changes: 44 additions & 0 deletions src/editor/sentry_editor_export_plugin_ios.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "sentry_editor_export_plugin_ios.h"

#ifdef TOOLS_ENABLED

#include "export_utils.h"
#include "gen/sdk_version.gen.h"
#include "sentry/logging/print.h"

using namespace sentry::editor;

String SentryEditorExportPluginIOS::_get_name() const {
return "SentryEditorExportPluginIOS";
}

bool SentryEditorExportPluginIOS::_supports_platform(const Ref<EditorExportPlatform> &p_platform) const {
return p_platform->get_os_name() == "iOS";
}

TypedArray<Dictionary> SentryEditorExportPluginIOS::_get_export_options(const Ref<EditorExportPlatform> &p_platform) const {
TypedArray<Dictionary> options;
// HACK: Adding a hidden option so we can show a warning at the bottom of the export dialog.
options.push_back(make_hidden_export_check_option());
return options;
}

String SentryEditorExportPluginIOS::_get_export_option_warning(const Ref<EditorExportPlatform> &p_platform, const String &p_option) const {
// HACK: Godot shows bottom-bar warnings through a separate code path that only checks plugin-owned options.
if (is_builtin_option_or_hidden_export_option(p_option, "application/min_ios_version")) {
String min_ios_version = get_option("application/min_ios_version");
if (min_ios_version.to_float() < SENTRY_IOS_MIN_VERSION) {
return vformat("Sentry requires \"Min iOS version\" %.1f or higher. Please adjust this setting.", SENTRY_IOS_MIN_VERSION);
}
}
return String();
}

void SentryEditorExportPluginIOS::_export_end() {
String min_ios_version = get_option("application/min_ios_version");
if (min_ios_version.to_float() < SENTRY_IOS_MIN_VERSION) {
ERR_PRINT_ED(vformat("Sentry requires \"Min iOS version\" to be %.1f or higher. The export completed, but the app may fail App Store Connect validation. Please update this export setting before distributing your app.", SENTRY_IOS_MIN_VERSION));
}
}

#endif // TOOLS_ENABLED
26 changes: 26 additions & 0 deletions src/editor/sentry_editor_export_plugin_ios.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#ifdef TOOLS_ENABLED

#include <godot_cpp/classes/editor_export_platform.hpp>
#include <godot_cpp/classes/editor_export_plugin.hpp>

using namespace godot;

class SentryEditorExportPluginIOS : public EditorExportPlugin {
GDCLASS(SentryEditorExportPluginIOS, EditorExportPlugin);

protected:
static void _bind_methods() {}

public:
virtual String _get_name() const override;
virtual bool _supports_platform(const Ref<EditorExportPlatform> &p_platform) const override;
virtual TypedArray<Dictionary> _get_export_options(const Ref<EditorExportPlatform> &p_platform) const override;
virtual String _get_export_option_warning(const Ref<EditorExportPlatform> &p_platform, const String &p_option) const override;
virtual void _export_end() override;

SentryEditorExportPluginIOS() = default;
};

#endif // TOOLS_ENABLED
2 changes: 1 addition & 1 deletion src/editor/sentry_editor_export_plugin_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class SentryEditorExportPluginUnix : public EditorExportPlugin {
virtual void _export_end() override;
};

#endif // # TOOLS_ENABLED && !WINDOWS_ENABLED
#endif // TOOLS_ENABLED && !WINDOWS_ENABLED
10 changes: 7 additions & 3 deletions src/editor/sentry_editor_export_plugin_web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

#ifdef TOOLS_ENABLED

#include "export_utils.h"
#include "sentry/logging/print.h"

#include <godot_cpp/classes/dir_access.hpp>
#include <godot_cpp/classes/project_settings.hpp>

using namespace sentry::editor;

String SentryEditorExportPluginWeb::_get_name() const {
return "SentryEditorExportPluginWeb";
}
Expand All @@ -21,6 +24,8 @@ TypedArray<Dictionary> SentryEditorExportPluginWeb::_get_export_options(const Re
option["option"] = Dictionary(PropertyInfo(Variant::BOOL, "sentry/inject_script"));
option["default_value"] = true;
options.push_back(option);
// HACK: Adding a hidden option so we can show a warning at the bottom of the export dialog.
options.push_back(make_hidden_export_check_option());
return options;
}

Expand Down Expand Up @@ -85,9 +90,8 @@ void SentryEditorExportPluginWeb::_export_begin(const PackedStringArray &p_featu
}

String SentryEditorExportPluginWeb::_get_export_option_warning(const Ref<EditorExportPlatform> &p_platform, const String &p_option) const {
// HACK: Also check "sentry/inject_script" so the warning appears at the bottom of the export dialog.
// Godot shows bottom-bar warnings through a separate code path that only checks plugin-owned options.
if ((p_option == "variant/extensions_support" || p_option == "sentry/inject_script") &&
// HACK: Godot shows bottom-bar warnings through a separate code path that only checks plugin-owned options.
if (is_builtin_option_or_hidden_export_option(p_option, "variant/extensions_support") &&
get_option("variant/extensions_support") == Variant(false)) {
return "Sentry requires \"Extension Support\" to be enabled for Web exports.";
}
Expand Down
11 changes: 11 additions & 0 deletions src/editor/sentry_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#ifdef TOOLS_ENABLED

#include "editor/sentry_editor_export_plugin_android.h"
#include "editor/sentry_editor_export_plugin_ios.h"
#include "editor/sentry_editor_export_plugin_unix.h"
#include "editor/sentry_editor_export_plugin_web.h"
#include "sentry/logging/print.h"
Expand All @@ -28,6 +29,11 @@ void SentryEditorPlugin::_notification(int p_what) {
web_export_plugin = Ref(memnew(SentryEditorExportPluginWeb));
}
add_export_plugin(web_export_plugin);

if (ios_export_plugin.is_null()) {
ios_export_plugin = Ref(memnew(SentryEditorExportPluginIOS));
}
add_export_plugin(ios_export_plugin);
} break;

case NOTIFICATION_EXIT_TREE: {
Expand All @@ -47,6 +53,11 @@ void SentryEditorPlugin::_notification(int p_what) {
remove_export_plugin(web_export_plugin);
web_export_plugin.unref();
}

if (ios_export_plugin.is_valid()) {
remove_export_plugin(ios_export_plugin);
ios_export_plugin.unref();
}
} break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/editor/sentry_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SentryEditorPlugin : public EditorPlugin {
Ref<EditorExportPlugin> android_export_plugin;
Ref<EditorExportPlugin> unix_export_plugin;
Ref<EditorExportPlugin> web_export_plugin;
Ref<EditorExportPlugin> ios_export_plugin;

protected:
static void _bind_methods() {}
Expand Down
2 changes: 2 additions & 0 deletions src/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

#ifdef TOOLS_ENABLED
#include "editor/sentry_editor_export_plugin_android.h"
#include "editor/sentry_editor_export_plugin_ios.h"
#include "editor/sentry_editor_export_plugin_unix.h"
#include "editor/sentry_editor_export_plugin_web.h"
#include "editor/sentry_editor_plugin.h"
Expand Down Expand Up @@ -120,6 +121,7 @@ void register_editor_classes() {
#ifdef TOOLS_ENABLED
GDREGISTER_INTERNAL_CLASS(SentryEditorExportPluginAndroid);
GDREGISTER_INTERNAL_CLASS(SentryEditorExportPluginWeb);
GDREGISTER_INTERNAL_CLASS(SentryEditorExportPluginIOS);
GDREGISTER_INTERNAL_CLASS(SentryEditorPlugin);

#ifndef WINDOWS_ENABLED
Expand Down
Loading