From 1f20ce3d6c4e80fd867a1433650f2e221cdf9196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Thu, 21 Aug 2025 10:33:36 +0300 Subject: [PATCH] Fix build with Godot 4.5. --- SConstruct | 4 +++ plugins/apn/godot_apn_delegate.mm | 12 ++++++- plugins/apn/godot_app_delegate_extension.h | 8 ++++- plugins/apn/godot_app_delegate_extension.m | 41 +++++++++++++++++++++- plugins/camera/camera_ios.h | 1 + plugins/camera/camera_ios.mm | 8 +++++ plugins/gamecenter/game_center.mm | 5 +++ plugins/icloud/icloud.mm | 4 +++ plugins/photo_picker/photo_picker.mm | 5 +++ 9 files changed, 85 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index 8c40603..d9e5154 100644 --- a/SConstruct +++ b/SConstruct @@ -144,6 +144,10 @@ else: print("No valid version to set flags for.") quit(); +if env['version'] == '4.0' and env['plugin'] == 'arkit': + print("'arkit' plugin is 3.x only.") + quit(); + # Adding header files if env['version'] == '3.x': env.Append(CPPPATH=[ diff --git a/plugins/apn/godot_apn_delegate.mm b/plugins/apn/godot_apn_delegate.mm index 4069ed1..374fca5 100644 --- a/plugins/apn/godot_apn_delegate.mm +++ b/plugins/apn/godot_apn_delegate.mm @@ -35,7 +35,11 @@ #import "godot_user_notification_delegate.h" #if VERSION_MAJOR == 4 +#if VERSION_MINOR == 5 +#import "drivers/apple_embedded/godot_app_delegate.h" +#else #import "platform/ios/godot_app_delegate.h" +#endif #else #import "platform/iphone/godot_app_delegate.h" #endif @@ -43,7 +47,9 @@ struct APNSInitializer { APNSInitializer() { -#if VERSION_MAJOR == 4 && VERSION_MINOR >= 4 +#if VERSION_MAJOR == 4 && VERSION_MINOR >= 5 + [GDTApplicationDelegate addService:[GodotAPNAppDelegate shared]]; +#elif VERSION_MAJOR == 4 && VERSION_MINOR == 4 [GodotApplicationDelegate addService:[GodotAPNAppDelegate shared]]; #else [GodotApplicalitionDelegate addService:[GodotAPNAppDelegate shared]]; @@ -94,7 +100,11 @@ - (void)application:(UIApplication *)application didRegisterForRemoteNotificatio } String device_token; +#if VERSION_MAJOR == 4 && VERSION_MINOR >= 5 + device_token.append_utf8([[token copy] UTF8String]); +#else device_token.parse_utf8([[token copy] UTF8String]); +#endif APNPlugin::get_singleton()->update_device_token(device_token); } diff --git a/plugins/apn/godot_app_delegate_extension.h b/plugins/apn/godot_app_delegate_extension.h index dae9bca..ed46737 100644 --- a/plugins/apn/godot_app_delegate_extension.h +++ b/plugins/apn/godot_app_delegate_extension.h @@ -31,12 +31,18 @@ #include "core/version.h" #if VERSION_MAJOR == 4 +#if VERSION_MINOR == 5 +#import "drivers/apple_embedded/godot_app_delegate.h" +#else #import "platform/ios/godot_app_delegate.h" +#endif #else #import "platform/iphone/godot_app_delegate.h" #endif -#if VERSION_MAJOR == 4 && VERSION_MINOR >= 4 +#if VERSION_MAJOR == 4 && VERSION_MINOR >= 5 +@interface GDTApplicationDelegate (PushNotifications) +#elif VERSION_MAJOR == 4 && VERSION_MINOR == 4 @interface GodotApplicationDelegate (PushNotifications) #else @interface GodotApplicalitionDelegate (PushNotifications) diff --git a/plugins/apn/godot_app_delegate_extension.m b/plugins/apn/godot_app_delegate_extension.m index 4f04b65..d6fca98 100644 --- a/plugins/apn/godot_app_delegate_extension.m +++ b/plugins/apn/godot_app_delegate_extension.m @@ -30,7 +30,46 @@ #include "godot_app_delegate_extension.h" -#if VERSION_MAJOR == 4 && VERSION_MINOR >= 4 +#if VERSION_MAJOR == 4 && VERSION_MINOR >= 5 + +@implementation GDTApplicationDelegate (PushNotifications) + +- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { + for (GDTAppDelegateServiceProtocol *service in GDTApplicationDelegate.services) { + if (![service respondsToSelector:_cmd]) { + continue; + } + + [service application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; + } +} + +- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { + for (GDTAppDelegateServiceProtocol *service in GDTApplicationDelegate.services) { + if (![service respondsToSelector:_cmd]) { + continue; + } + + [service application:application didFailToRegisterForRemoteNotificationsWithError:error]; + } +} + +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler { + for (GDTAppDelegateServiceProtocol *service in GDTApplicationDelegate.services) { + if (![service respondsToSelector:_cmd]) { + continue; + } + + [service application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; + } + + completionHandler(UIBackgroundFetchResultNoData); +} + +@end + +#elif VERSION_MAJOR == 4 && VERSION_MINOR == 4 + @implementation GodotApplicationDelegate (PushNotifications) - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { diff --git a/plugins/camera/camera_ios.h b/plugins/camera/camera_ios.h index f398116..f1aec9f 100644 --- a/plugins/camera/camera_ios.h +++ b/plugins/camera/camera_ios.h @@ -35,6 +35,7 @@ #include "servers/camera_server.h" class CameraIOS : public CameraServer { + private: public: CameraIOS(); diff --git a/plugins/camera/camera_ios.mm b/plugins/camera/camera_ios.mm index 35efc94..973ace8 100644 --- a/plugins/camera/camera_ios.mm +++ b/plugins/camera/camera_ios.mm @@ -257,6 +257,9 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM // CameraFeedIOS - Subclass for camera feeds in iOS class CameraFeedIOS : public CameraFeed { +#if VERSION_MAJOR == 4 && VERSION_MINOR >= 5 +GDSOFTCLASS(CameraFeedIOS, CameraFeed); +#endif private: AVCaptureDevice *device; MyCaptureSession *capture_session; @@ -270,8 +273,13 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM void set_device(AVCaptureDevice *p_device); +#if VERSION_MAJOR == 4 && VERSION_MINOR >= 5 + bool activate_feed() override; + void deactivate_feed() override; +#else bool activate_feed(); void deactivate_feed(); +#endif }; AVCaptureDevice *CameraFeedIOS::get_device() const { diff --git a/plugins/gamecenter/game_center.mm b/plugins/gamecenter/game_center.mm index f027ab7..316c20c 100644 --- a/plugins/gamecenter/game_center.mm +++ b/plugins/gamecenter/game_center.mm @@ -33,8 +33,13 @@ #import "game_center_delegate.h" #if VERSION_MAJOR == 4 +#if VERSION_MINOR == 5 +#import "drivers/apple_embedded/godot_app_delegate.h" +#import "drivers/apple_embedded/view_controller.h" +#else #import "platform/ios/app_delegate.h" #import "platform/ios/view_controller.h" +#endif #else #import "platform/iphone/app_delegate.h" #import "platform/iphone/view_controller.h" diff --git a/plugins/icloud/icloud.mm b/plugins/icloud/icloud.mm index 20ab2f1..b38366b 100644 --- a/plugins/icloud/icloud.mm +++ b/plugins/icloud/icloud.mm @@ -31,7 +31,11 @@ #include "icloud.h" #if VERSION_MAJOR == 4 +#if VERSION_MINOR == 5 +#import "drivers/apple_embedded/godot_app_delegate.h" +#else #import "platform/ios/app_delegate.h" +#endif #else #import "platform/iphone/app_delegate.h" #endif diff --git a/plugins/photo_picker/photo_picker.mm b/plugins/photo_picker/photo_picker.mm index 8cb87dd..9dff004 100644 --- a/plugins/photo_picker/photo_picker.mm +++ b/plugins/photo_picker/photo_picker.mm @@ -34,8 +34,13 @@ #import #if VERSION_MAJOR == 4 +#if VERSION_MINOR == 5 +#import "drivers/apple_embedded/godot_app_delegate.h" +#import "drivers/apple_embedded/view_controller.h" +#else #import "platform/ios/app_delegate.h" #import "platform/ios/view_controller.h" +#endif #else #import "platform/iphone/app_delegate.h" #import "platform/iphone/view_controller.h"