Skip to content

Commit ec3f304

Browse files
committed
Merge pull request #113455 from bruvzg/ios_p
[iOS] Fix use of `godot_path`.
2 parents 8749308 + 358d799 commit ec3f304

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

core/config/project_settings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
718718
// We need to test both possibilities as extensions for Linux binaries are optional
719719
// (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
720720

721-
#ifdef MACOS_ENABLED
721+
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
722722
if (!found) {
723723
// Attempt to load PCK from macOS .app bundle resources.
724724
found = _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().path_join(exec_basename + ".pck"), false, 0, true) || _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().path_join(exec_filename + ".pck"), false, 0, true);
@@ -777,7 +777,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
777777
return err;
778778
}
779779

780-
#ifdef MACOS_ENABLED
780+
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
781781
// Attempt to load project file from macOS .app bundle resources.
782782
resource_path = OS::get_singleton()->get_bundle_resource_dir();
783783
if (!resource_path.is_empty()) {

drivers/apple_embedded/main_utilities.mm

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ void change_to_launch_dir(char **p_args) {
5252
}
5353
}
5454

55-
int add_path(int p_argc, char **p_args) {
56-
NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
57-
if (!str) {
58-
return p_argc;
59-
}
60-
61-
p_args[p_argc++] = (char *)"--path";
62-
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
63-
p_args[p_argc] = nullptr;
64-
65-
return p_argc;
66-
}
67-
6855
int add_cmdline(int p_argc, char **p_args) {
6956
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
7057
if (!arr) {
@@ -89,7 +76,6 @@ int process_args(int p_argc, char **p_args, char **r_args) {
8976
r_args[i] = p_args[i];
9077
}
9178
r_args[p_argc] = nullptr;
92-
p_argc = add_path(p_argc, r_args);
9379
p_argc = add_cmdline(p_argc, r_args);
9480
return p_argc;
9581
}

drivers/apple_embedded/os_apple_embedded.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class OS_AppleEmbedded : public OS_Unix {
118118
virtual String get_cache_path() const override;
119119
virtual String get_temp_path() const override;
120120
virtual String get_resource_dir() const override;
121+
virtual String get_bundle_resource_dir() const override;
121122

122123
virtual String get_locale() const override;
123124

drivers/apple_embedded/os_apple_embedded.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,15 @@ Rect2 fit_keep_aspect_covered(const Vector2 &p_container, const Vector2 &p_rect)
412412
#endif
413413
}
414414

415+
String OS_AppleEmbedded::get_bundle_resource_dir() const {
416+
NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
417+
if (!str) {
418+
return OS_Unix::get_bundle_resource_dir();
419+
} else {
420+
return String::utf8([str cStringUsingEncoding:NSUTF8StringEncoding]);
421+
}
422+
}
423+
415424
String OS_AppleEmbedded::get_locale() const {
416425
NSString *preferredLanguage = [NSLocale preferredLanguages].firstObject;
417426

main/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
996996

997997
#if !defined(OVERRIDE_PATH_ENABLED) && !defined(TOOLS_ENABLED)
998998
String old_cwd = OS::get_singleton()->get_cwd();
999-
#ifdef MACOS_ENABLED
999+
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
10001000
String new_cwd = OS::get_singleton()->get_bundle_resource_dir();
10011001
if (new_cwd.is_empty() || !new_cwd.is_absolute_path()) {
10021002
new_cwd = OS::get_singleton()->get_executable_path().get_base_dir();

0 commit comments

Comments
 (0)