Enable SDL_LoadObject on iOS 8+ and tvOS.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h
index 304c892..470985f 100644
--- a/include/SDL_config_iphoneos.h
+++ b/include/SDL_config_iphoneos.h
@@ -119,11 +119,7 @@
#define SDL_JOYSTICK_MFI 1
/* Enable Unix style SO loading */
-/* Technically this works, but violates the iOS dev agreement prior to iOS 8 */
-/* #define SDL_LOADSO_DLOPEN 1 */
-
-/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
-#define SDL_LOADSO_DISABLED 1
+#define SDL_LOADSO_DLOPEN 1
/* Enable various threading systems */
#define SDL_THREAD_PTHREAD 1
diff --git a/premake/Xcode-iOS/SDL_config_premake.h b/premake/Xcode-iOS/SDL_config_premake.h
index c4a8a1b..537d305 100644
--- a/premake/Xcode-iOS/SDL_config_premake.h
+++ b/premake/Xcode-iOS/SDL_config_premake.h
@@ -150,8 +150,8 @@
#ifndef SDL_VIDEO_RENDER_OGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 1
#endif
-#ifndef SDL_LOADSO_DISABLED
-#define SDL_LOADSO_DISABLED 1
+#ifndef SDL_LOADSO_DLOPEN
+#define SDL_LOADSO_DLOPEN 1
#endif
#ifndef SDL_HAPTIC_DISABLED
#define SDL_HAPTIC_DISABLED 1
diff --git a/premake/projects/SDL2.lua b/premake/projects/SDL2.lua
index 2f64e0e..1ab2346 100755
--- a/premake/projects/SDL2.lua
+++ b/premake/projects/SDL2.lua
@@ -369,7 +369,7 @@ SDL_project "SDL2"
["SDL_AUDIO_DRIVER_COREAUDIO"] = 1,
["SDL_JOYSTICK_MFI"] = 1,
["SDL_HAPTIC_DISABLED"] = 1,
- ["SDL_LOADSO_DISABLED"] = 1,
+ ["SDL_LOADSO_DLOPEN"] = 1,
["SDL_THREAD_PTHREAD"] = 1,
["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
["SDL_TIMER_UNIX"] = 1,
diff --git a/src/loadso/dlopen/SDL_sysloadso.c b/src/loadso/dlopen/SDL_sysloadso.c
index 03ffae1..7b30b77 100644
--- a/src/loadso/dlopen/SDL_sysloadso.c
+++ b/src/loadso/dlopen/SDL_sysloadso.c
@@ -30,11 +30,25 @@
#include "SDL_loadso.h"
+#if SDL_VIDEO_DRIVER_UIKIT
+#include "../../video/uikit/SDL_uikitvideo.h"
+#endif
+
void *
SDL_LoadObject(const char *sofile)
{
- void *handle = dlopen(sofile, RTLD_NOW|RTLD_LOCAL);
- const char *loaderror = (char *) dlerror();
+ void *handle;
+ const char *loaderror;
+
+#if SDL_VIDEO_DRIVER_UIKIT
+ if (!UIKit_IsSystemVersionAtLeast(8.0)) {
+ SDL_SetError("SDL_LoadObject requires iOS 8+");
+ return NULL;
+ }
+#endif
+
+ handle = dlopen(sofile, RTLD_NOW|RTLD_LOCAL);
+ loaderror = (char *) dlerror();
if (handle == NULL) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
diff --git a/src/video/uikit/SDL_uikitvideo.h b/src/video/uikit/SDL_uikitvideo.h
index 836cf18..aafb714 100644
--- a/src/video/uikit/SDL_uikitvideo.h
+++ b/src/video/uikit/SDL_uikitvideo.h
@@ -21,20 +21,25 @@
#ifndef _SDL_uikitvideo_h
#define _SDL_uikitvideo_h
-#include <UIKit/UIKit.h>
-
#include "../SDL_sysvideo.h"
+#ifdef __OBJC__
+
+#include <UIKit/UIKit.h>
+
@interface SDL_VideoData : NSObject
@property (nonatomic) id pasteboardObserver;
@end
+CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
+
+#endif /* __OBJC__ */
+
void UIKit_SuspendScreenSaver(_THIS);
-BOOL UIKit_IsSystemVersionAtLeast(double version);
-CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
+SDL_bool UIKit_IsSystemVersionAtLeast(double version);
#endif /* _SDL_uikitvideo_h */
diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m
index c6d207a..9cfc922 100644
--- a/src/video/uikit/SDL_uikitvideo.m
+++ b/src/video/uikit/SDL_uikitvideo.m
@@ -167,7 +167,7 @@ UIKit_SuspendScreenSaver(_THIS)
}
}
-BOOL
+SDL_bool
UIKit_IsSystemVersionAtLeast(double version)
{
return [[UIDevice currentDevice].systemVersion doubleValue] >= version;