Browse Source

iOS Modules: separate main platform code from modules

Moved previously builtin modules 'GameCenter', 'AppStore', 'iCloud' to separate modules to be represented as plugin.
Modified 'ARKit' and 'Camera' to not be builtin into engine and work as plugin.
Changed platform code so it's not affected by the move.
Modified Xcode project file to remove parameters that doesn't make any effect.
Added basic '.gdip' plugin config file.
Sergey Minakov 5 years ago
parent
commit
30783d57cc
45 changed files with 594 additions and 224 deletions
  1. 0 75
      misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj
  2. 8 1
      modules/SCsub
  3. 18 0
      modules/arkit/arkit.gdip
  4. 2 2
      modules/arkit/arkit_module.cpp
  5. 1 1
      modules/arkit/arkit_module.h
  6. 1 11
      modules/camera/SCsub
  7. 1 1
      modules/camera/config.py
  8. 0 6
      modules/camera/register_types.cpp
  9. 15 0
      modules/camera_iphone/SCsub
  10. 18 0
      modules/camera_iphone/camera.gdip
  11. 0 0
      modules/camera_iphone/camera_ios.h
  12. 0 0
      modules/camera_iphone/camera_ios.mm
  13. 40 0
      modules/camera_iphone/camera_module.cpp
  14. 32 0
      modules/camera_iphone/camera_module.h
  15. 6 0
      modules/camera_iphone/config.py
  16. 15 0
      modules/gamecenter/SCsub
  17. 6 0
      modules/gamecenter/config.py
  18. 0 4
      modules/gamecenter/game_center.h
  19. 14 23
      modules/gamecenter/game_center.mm
  20. 35 0
      modules/gamecenter/game_center_delegate.h
  21. 45 0
      modules/gamecenter/game_center_delegate.mm
  22. 48 0
      modules/gamecenter/game_center_module.cpp
  23. 32 0
      modules/gamecenter/game_center_module.h
  24. 17 0
      modules/gamecenter/gamecenter.gdip
  25. 15 0
      modules/icloud/SCsub
  26. 6 0
      modules/icloud/config.py
  27. 17 0
      modules/icloud/icloud.gdip
  28. 0 4
      modules/icloud/icloud.h
  29. 1 13
      modules/icloud/icloud.mm
  30. 48 0
      modules/icloud/icloud_module.cpp
  31. 32 0
      modules/icloud/icloud_module.h
  32. 15 0
      modules/inappstore/SCsub
  33. 6 0
      modules/inappstore/config.py
  34. 0 4
      modules/inappstore/in_app_store.h
  35. 0 4
      modules/inappstore/in_app_store.mm
  36. 48 0
      modules/inappstore/in_app_store_module.cpp
  37. 32 0
      modules/inappstore/in_app_store_module.h
  38. 17 0
      modules/inappstore/inappstore.gdip
  39. 0 3
      platform/iphone/SCsub
  40. 1 0
      platform/iphone/app_delegate.mm
  41. 0 15
      platform/iphone/detect.py
  42. 0 12
      platform/iphone/os_iphone.h
  43. 0 33
      platform/iphone/os_iphone.mm
  44. 1 2
      platform/iphone/view_controller.h
  45. 1 10
      platform/iphone/view_controller.mm

+ 0 - 75
misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj

@@ -153,81 +153,6 @@
 						DevelopmentTeam = $team_id;
 						ProvisioningStyle = Automatic;
 						SystemCapabilities = {
-							com.apple.AccessWiFi = {
-								enabled = $access_wifi;
-							};
-							com.apple.ApplePay = {
-								enabled = 0;
-							};
-							com.apple.ApplicationGroups.iOS = {
-								enabled = 0;
-							};
-							com.apple.AutoFillCredentialProvider = {
-								enabled = 0;
-							};
-							com.apple.BackgroundModes = {
-								enabled = 0;
-							};
-							com.apple.ClassKit = {
-								enabled = 0;
-							};
-							com.apple.DataProtection = {
-								enabled = 0;
-							};
-							com.apple.GameCenter.iOS = {
-								enabled = $game_center;
-							};
-							com.apple.HealthKit = {
-								enabled = 0;
-							};
-							com.apple.HomeKit = {
-								enabled = 0;
-							};
-							com.apple.HotspotConfiguration = {
-								enabled = 0;
-							};
-							com.apple.InAppPurchase = {
-								enabled = $in_app_purchases;
-							};
-							com.apple.InterAppAudio = {
-								enabled = 0;
-							};
-							com.apple.Keychain = {
-								enabled = 0;
-							};
-							com.apple.Maps.iOS = {
-								enabled = 0;
-							};
-							com.apple.Multipath = {
-								enabled = 0;
-							};
-							com.apple.NearFieldCommunicationTagReading = {
-								enabled = 0;
-							};
-							com.apple.NetworkExtensions.iOS = {
-								enabled = 0;
-							};
-							com.apple.Push = {
-								enabled = $push_notifications;
-							};
-							com.apple.SafariKeychain = {
-								enabled = 0;
-							};
-							com.apple.Siri = {
-								enabled = 0;
-							};
-							com.apple.VPNLite = {
-								enabled = 0;
-							};
-							com.apple.WAC = {
-								enabled = 0;
-							};
-							com.apple.Wallet = {
-								enabled = 0;
-							};
-							com.apple.iCloud = {
-								enabled = 0;
-							};
 						};
 					};
 				};

+ 8 - 1
modules/SCsub

@@ -47,7 +47,14 @@ for name, path in env.module_list.items():
 
     # Some modules are not linked automatically but can be enabled optionally
     # on iOS, so we handle those specially.
-    if env["platform"] == "iphone" and name in ["arkit", "camera"]:
+    if env["platform"] == "iphone" and name in [
+        "arkit",
+        "camera",
+        "camera_iphone",
+        "gamecenter",
+        "inappstore",
+        "icloud",
+    ]:
         continue
 
     lib = env_modules.add_library("module_%s" % name, env.modules_sources)

+ 18 - 0
modules/arkit/arkit.gdip

@@ -0,0 +1,18 @@
+[config]
+name="ARKit"
+binary="arkit_lib.a"
+
+initialization="register_arkit_types"
+deinitialization="unregister_arkit_types"
+
+[dependencies]
+linked=[]
+embedded=[]
+system=["AVFoundation.framework", "ARKit.framework"]
+
+capabilities=["arkit"]
+
+files=[]
+
+[plist]
+NSCameraUsageDescription="Device camera is used for some functionality"

+ 2 - 2
modules/arkit/register_types.cpp → modules/arkit/arkit_module.cpp

@@ -1,5 +1,5 @@
 /*************************************************************************/
-/*  register_types.cpp                                                   */
+/*  arkit_module.cpp                                                     */
 /*************************************************************************/
 /*                       This file is part of:                           */
 /*                           GODOT ENGINE                                */
@@ -28,7 +28,7 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#include "register_types.h"
+#include "arkit_module.h"
 
 #include "arkit_interface.h"
 

+ 1 - 1
modules/arkit/register_types.h → modules/arkit/arkit_module.h

@@ -1,5 +1,5 @@
 /*************************************************************************/
-/*  register_types.h                                                     */
+/*  arkit_module.h                                                       */
 /*************************************************************************/
 /*                       This file is part of:                           */
 /*                           GODOT ENGINE                                */

+ 1 - 11
modules/camera/SCsub

@@ -5,17 +5,7 @@ Import("env_modules")
 
 env_camera = env_modules.Clone()
 
-if env["platform"] == "iphone":
-    # (iOS) Enable module support
-    env_camera.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])
-
-    # (iOS) Build as separate static library
-    modules_sources = []
-    env_camera.add_source_files(modules_sources, "register_types.cpp")
-    env_camera.add_source_files(modules_sources, "camera_ios.mm")
-    mod_lib = env_modules.add_library("#bin/libgodot_camera_module" + env["LIBSUFFIX"], modules_sources)
-
-elif env["platform"] == "windows":
+if env["platform"] == "windows":
     env_camera.add_source_files(env.modules_sources, "register_types.cpp")
     env_camera.add_source_files(env.modules_sources, "camera_win.cpp")
 

+ 1 - 1
modules/camera/config.py

@@ -1,5 +1,5 @@
 def can_build(env, platform):
-    return platform == "iphone" or platform == "osx" or platform == "windows"
+    return platform == "osx" or platform == "windows"
 
 
 def configure(env):

+ 0 - 6
modules/camera/register_types.cpp

@@ -33,9 +33,6 @@
 #if defined(WINDOWS_ENABLED)
 #include "camera_win.h"
 #endif
-#if defined(IPHONE_ENABLED)
-#include "camera_ios.h"
-#endif
 #if defined(OSX_ENABLED)
 #include "camera_osx.h"
 #endif
@@ -44,9 +41,6 @@ void register_camera_types() {
 #if defined(WINDOWS_ENABLED)
 	CameraServer::make_default<CameraWindows>();
 #endif
-#if defined(IPHONE_ENABLED)
-	CameraServer::make_default<CameraIOS>();
-#endif
 #if defined(OSX_ENABLED)
 	CameraServer::make_default<CameraOSX>();
 #endif

+ 15 - 0
modules/camera_iphone/SCsub

@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+Import("env")
+Import("env_modules")
+
+env_camera = env_modules.Clone()
+
+# (iOS) Enable module support
+env_camera.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])
+
+# (iOS) Build as separate static library
+modules_sources = []
+env_camera.add_source_files(modules_sources, "*.cpp")
+env_camera.add_source_files(modules_sources, "*.mm")
+mod_lib = env_modules.add_library("#bin/libgodot_camera_module" + env["LIBSUFFIX"], modules_sources)

+ 18 - 0
modules/camera_iphone/camera.gdip

@@ -0,0 +1,18 @@
+[config]
+name="Camera"
+binary="camera_lib.a"
+
+initialization="register_camera_types"
+deinitialization="unregister_camera_types"
+
+[dependencies]
+linked=[]
+embedded=[]
+system=["AVFoundation.framework"]
+
+capabilities=[]
+
+files=[]
+
+[plist]
+NSCameraUsageDescription="Device camera is used for some functionality"

+ 0 - 0
modules/camera/camera_ios.h → modules/camera_iphone/camera_ios.h


+ 0 - 0
modules/camera/camera_ios.mm → modules/camera_iphone/camera_ios.mm


+ 40 - 0
modules/camera_iphone/camera_module.cpp

@@ -0,0 +1,40 @@
+/*************************************************************************/
+/*  camera_module.cpp                                                    */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+#include "camera_module.h"
+
+#include "camera_ios.h"
+
+void register_camera_types() {
+	CameraServer::make_default<CameraIOS>();
+}
+
+void unregister_camera_types() {
+}

+ 32 - 0
modules/camera_iphone/camera_module.h

@@ -0,0 +1,32 @@
+/*************************************************************************/
+/*  camera_module.h                                                      */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+void register_camera_types();
+void unregister_camera_types();

+ 6 - 0
modules/camera_iphone/config.py

@@ -0,0 +1,6 @@
+def can_build(env, platform):
+    return platform == "iphone"
+
+
+def configure(env):
+    pass

+ 15 - 0
modules/gamecenter/SCsub

@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+Import("env")
+Import("env_modules")
+
+env_gamecenter = env_modules.Clone()
+
+# (iOS) Enable module support
+env_gamecenter.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])
+
+# (iOS) Build as separate static library
+modules_sources = []
+env_gamecenter.add_source_files(modules_sources, "*.cpp")
+env_gamecenter.add_source_files(modules_sources, "*.mm")
+mod_lib = env_modules.add_library("#bin/libgodot_gamecenter_module" + env["LIBSUFFIX"], modules_sources)

+ 6 - 0
modules/gamecenter/config.py

@@ -0,0 +1,6 @@
+def can_build(env, platform):
+    return platform == "iphone"
+
+
+def configure(env):
+    pass

+ 0 - 4
platform/iphone/game_center.h → modules/gamecenter/game_center.h

@@ -28,8 +28,6 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#ifdef GAME_CENTER_ENABLED
-
 #ifndef GAME_CENTER_H
 #define GAME_CENTER_H
 
@@ -71,5 +69,3 @@ public:
 };
 
 #endif
-
-#endif

+ 14 - 23
platform/iphone/game_center.mm → modules/gamecenter/game_center.mm

@@ -28,28 +28,15 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#ifdef GAME_CENTER_ENABLED
-
 #include "game_center.h"
+#import "platform/iphone/app_delegate.h"
 
-#ifdef __IPHONE_9_0
-
-#import <GameKit/GameKit.h>
-extern "C" {
-
-#else
-
-extern "C" {
+#import "game_center_delegate.h"
+#import "platform/iphone/view_controller.h"
 #import <GameKit/GameKit.h>
 
-#endif
-
-#import "app_delegate.h"
-};
-
-#import "view_controller.h"
-
 GameCenter *GameCenter::instance = NULL;
+GodotGameCenterDelegate *gameCenterDelegate = nil;
 
 void GameCenter::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("authenticate"), &GameCenter::authenticate);
@@ -76,7 +63,7 @@ Error GameCenter::authenticate() {
 	GKLocalPlayer *player = [GKLocalPlayer localPlayer];
 	ERR_FAIL_COND_V(![player respondsToSelector:@selector(authenticateHandler)], ERR_UNAVAILABLE);
 
-	ViewController *root_controller = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
+	UIViewController *root_controller = [[UIApplication sharedApplication] delegate].window.rootViewController;
 	ERR_FAIL_COND_V(!root_controller, FAILED);
 
 	// This handler is called several times.  First when the view needs to be shown, then again
@@ -305,10 +292,10 @@ Error GameCenter::show_game_center(Dictionary p_params) {
 	GKGameCenterViewController *controller = [[GKGameCenterViewController alloc] init];
 	ERR_FAIL_COND_V(!controller, FAILED);
 
-	ViewController *root_controller = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
+	UIViewController *root_controller = [[UIApplication sharedApplication] delegate].window.rootViewController;
 	ERR_FAIL_COND_V(!root_controller, FAILED);
 
-	controller.gameCenterDelegate = root_controller;
+	controller.gameCenterDelegate = gameCenterDelegate;
 	controller.viewState = view_state;
 	if (view_state == GKGameCenterViewControllerStateLeaderboards) {
 		controller.leaderboardIdentifier = nil;
@@ -382,8 +369,12 @@ GameCenter::GameCenter() {
 	ERR_FAIL_COND(instance != NULL);
 	instance = this;
 	authenticated = false;
-};
 
-GameCenter::~GameCenter() {}
+	gameCenterDelegate = [[GodotGameCenterDelegate alloc] init];
+};
 
-#endif
+GameCenter::~GameCenter() {
+	if (gameCenterDelegate) {
+		gameCenterDelegate = nil;
+	}
+}

+ 35 - 0
modules/gamecenter/game_center_delegate.h

@@ -0,0 +1,35 @@
+/*************************************************************************/
+/*  game_center_delegate.h                                               */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+#import <GameKit/GameKit.h>
+
+@interface GodotGameCenterDelegate : NSObject <GKGameCenterControllerDelegate>
+
+@end

+ 45 - 0
modules/gamecenter/game_center_delegate.mm

@@ -0,0 +1,45 @@
+/*************************************************************************/
+/*  game_center_delegate.mm                                              */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+#import "game_center_delegate.h"
+
+#include "game_center.h"
+
+@implementation GodotGameCenterDelegate
+
+- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController {
+	//[gameCenterViewController dismissViewControllerAnimated:YES completion:^{GameCenter::get_singleton()->game_center_closed();}];//version for signaling when overlay is completely gone
+	if (GameCenter::get_singleton()) {
+		GameCenter::get_singleton()->game_center_closed();
+	}
+	[gameCenterViewController dismissViewControllerAnimated:YES completion:nil];
+}
+
+@end

+ 48 - 0
modules/gamecenter/game_center_module.cpp

@@ -0,0 +1,48 @@
+/*************************************************************************/
+/*  game_center_module.cpp                                               */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+#include "game_center_module.h"
+
+#include "core/config/engine.h"
+
+#include "game_center.h"
+
+GameCenter *game_center;
+
+void register_gamecenter_types() {
+	game_center = memnew(GameCenter);
+	Engine::get_singleton()->add_singleton(Engine::Singleton("GameCenter", game_center));
+}
+
+void unregister_gamecenter_types() {
+	if (game_center) {
+		memdelete(game_center);
+	}
+}

+ 32 - 0
modules/gamecenter/game_center_module.h

@@ -0,0 +1,32 @@
+/*************************************************************************/
+/*  game_center_module.h                                                 */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+void register_gamecenter_types();
+void unregister_gamecenter_types();

+ 17 - 0
modules/gamecenter/gamecenter.gdip

@@ -0,0 +1,17 @@
+[config]
+name="GameCenter"
+binary="gamecenter_lib.a"
+
+initialization="register_gamecenter_types"
+deinitialization="unregister_gamecenter_types"
+
+[dependencies]
+linked=[]
+embedded=[]
+system=["GameKit.framework"]
+
+capabilities=["gamekit"]
+
+files=[]
+
+[plist]

+ 15 - 0
modules/icloud/SCsub

@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+Import("env")
+Import("env_modules")
+
+env_icloud = env_modules.Clone()
+
+# (iOS) Enable module support
+env_icloud.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])
+
+# (iOS) Build as separate static library
+modules_sources = []
+env_icloud.add_source_files(modules_sources, "*.cpp")
+env_icloud.add_source_files(modules_sources, "*.mm")
+mod_lib = env_modules.add_library("#bin/libgodot_icloud_module" + env["LIBSUFFIX"], modules_sources)

+ 6 - 0
modules/icloud/config.py

@@ -0,0 +1,6 @@
+def can_build(env, platform):
+    return platform == "iphone"
+
+
+def configure(env):
+    pass

+ 17 - 0
modules/icloud/icloud.gdip

@@ -0,0 +1,17 @@
+[config]
+name="iCloud"
+binary="icloud_lib.a"
+
+initialization="register_icloud_types"
+deinitialization="unregister_icloud_types"
+
+[dependencies]
+linked=[]
+embedded=[]
+system=[]
+
+capabilities=[]
+
+files=[]
+
+[plist]

+ 0 - 4
platform/iphone/icloud.h → modules/icloud/icloud.h

@@ -28,8 +28,6 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#ifdef ICLOUD_ENABLED
-
 #ifndef ICLOUD_H
 #define ICLOUD_H
 
@@ -60,5 +58,3 @@ public:
 };
 
 #endif
-
-#endif

+ 1 - 13
platform/iphone/icloud.mm → modules/icloud/icloud.mm

@@ -28,22 +28,12 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#ifdef ICLOUD_ENABLED
-
 #include "icloud.h"
 
-#ifndef __IPHONE_9_0
-extern "C" {
-#endif
-
-#import "app_delegate.h"
+#import "platform/iphone/app_delegate.h"
 
 #import <Foundation/Foundation.h>
 
-#ifndef __IPHONE_9_0
-};
-#endif
-
 ICloud *ICloud::instance = NULL;
 
 void ICloud::_bind_methods() {
@@ -353,5 +343,3 @@ ICloud::ICloud() {
 }
 
 ICloud::~ICloud() {}
-
-#endif

+ 48 - 0
modules/icloud/icloud_module.cpp

@@ -0,0 +1,48 @@
+/*************************************************************************/
+/*  icloud_module.cpp                                                    */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+#include "icloud_module.h"
+
+#include "core/config/engine.h"
+
+#include "icloud.h"
+
+ICloud *icloud;
+
+void register_icloud_types() {
+	icloud = memnew(ICloud);
+	Engine::get_singleton()->add_singleton(Engine::Singleton("ICloud", icloud));
+}
+
+void unregister_icloud_types() {
+	if (icloud) {
+		memdelete(icloud);
+	}
+}

+ 32 - 0
modules/icloud/icloud_module.h

@@ -0,0 +1,32 @@
+/*************************************************************************/
+/*  icloud_module.h                                                      */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+void register_icloud_types();
+void unregister_icloud_types();

+ 15 - 0
modules/inappstore/SCsub

@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+Import("env")
+Import("env_modules")
+
+env_inappstore = env_modules.Clone()
+
+# (iOS) Enable module support
+env_inappstore.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])
+
+# (iOS) Build as separate static library
+modules_sources = []
+env_inappstore.add_source_files(modules_sources, "*.cpp")
+env_inappstore.add_source_files(modules_sources, "*.mm")
+mod_lib = env_modules.add_library("#bin/libgodot_inappstore_module" + env["LIBSUFFIX"], modules_sources)

+ 6 - 0
modules/inappstore/config.py

@@ -0,0 +1,6 @@
+def can_build(env, platform):
+    return platform == "iphone"
+
+
+def configure(env):
+    pass

+ 0 - 4
platform/iphone/in_app_store.h → modules/inappstore/in_app_store.h

@@ -28,8 +28,6 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#ifdef STOREKIT_ENABLED
-
 #ifndef IN_APP_STORE_H
 #define IN_APP_STORE_H
 
@@ -77,5 +75,3 @@ public:
 };
 
 #endif
-
-#endif

+ 0 - 4
platform/iphone/in_app_store.mm → modules/inappstore/in_app_store.mm

@@ -28,8 +28,6 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#ifdef STOREKIT_ENABLED
-
 #include "in_app_store.h"
 
 #import <Foundation/Foundation.h>
@@ -411,5 +409,3 @@ InAppStore::~InAppStore() {
 	[[SKPaymentQueue defaultQueue] removeTransactionObserver:transactions_observer];
 	transactions_observer = nil;
 }
-
-#endif

+ 48 - 0
modules/inappstore/in_app_store_module.cpp

@@ -0,0 +1,48 @@
+/*************************************************************************/
+/*  in_app_store_module.cpp                                              */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+#include "in_app_store_module.h"
+
+#include "core/config/engine.h"
+
+#include "in_app_store.h"
+
+InAppStore *store_kit;
+
+void register_inappstore_types() {
+	store_kit = memnew(InAppStore);
+	Engine::get_singleton()->add_singleton(Engine::Singleton("InAppStore", store_kit));
+}
+
+void unregister_inappstore_types() {
+	if (store_kit) {
+		memdelete(store_kit);
+	}
+}

+ 32 - 0
modules/inappstore/in_app_store_module.h

@@ -0,0 +1,32 @@
+/*************************************************************************/
+/*  in_app_store_module.h                                                */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                      https://godotengine.org                          */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+
+void register_inappstore_types();
+void unregister_inappstore_types();

+ 17 - 0
modules/inappstore/inappstore.gdip

@@ -0,0 +1,17 @@
+[config]
+name="InAppStore"
+binary="inappstore_lib.a"
+
+initialization="register_inappstore_types"
+deinitialization="unregister_inappstore_types"
+
+[dependencies]
+linked=[]
+embedded=[]
+system=["StoreKit.framework"]
+
+capabilities=[]
+
+files=[]
+
+[plist]

+ 0 - 3
platform/iphone/SCsub

@@ -8,9 +8,6 @@ iphone_lib = [
     "main.m",
     "app_delegate.mm",
     "view_controller.mm",
-    "game_center.mm",
-    "in_app_store.mm",
-    "icloud.mm",
     "ios.mm",
     "vulkan_context_iphone.mm",
     "display_server_iphone.mm",

+ 1 - 0
platform/iphone/app_delegate.mm

@@ -36,6 +36,7 @@
 #include "os_iphone.h"
 #import "view_controller.h"
 
+#import <AVFoundation/AVFoundation.h>
 #import <AudioToolbox/AudioServices.h>
 
 #define kRenderingFrequency 60

+ 0 - 15
platform/iphone/detect.py

@@ -35,9 +35,6 @@ def get_opts():
             " validation layers)",
             False,
         ),
-        BoolVariable("game_center", "Support for game center", True),
-        BoolVariable("store_kit", "Support for in-app store", True),
-        BoolVariable("icloud", "Support for iCloud", True),
         BoolVariable("ios_exceptions", "Enable exceptions", False),
         ("ios_triple", "Triple for ios toolchain", ""),
     ]
@@ -222,18 +219,6 @@ def configure(env):
         ]
     )
 
-    # Feature options
-    if env["game_center"]:
-        env.Append(CPPDEFINES=["GAME_CENTER_ENABLED"])
-        env.Append(LINKFLAGS=["-framework", "GameKit"])
-
-    if env["store_kit"]:
-        env.Append(CPPDEFINES=["STOREKIT_ENABLED"])
-        env.Append(LINKFLAGS=["-framework", "StoreKit"])
-
-    if env["icloud"]:
-        env.Append(CPPDEFINES=["ICLOUD_ENABLED"])
-
     env.Prepend(
         CPPPATH=[
             "$IPHONESDK/usr/include",

+ 0 - 12
platform/iphone/os_iphone.h

@@ -35,9 +35,6 @@
 
 #include "drivers/coreaudio/audio_driver_coreaudio.h"
 #include "drivers/unix/os_unix.h"
-#include "game_center.h"
-#include "icloud.h"
-#include "in_app_store.h"
 #include "ios.h"
 #include "joypad_iphone.h"
 #include "servers/audio_server.h"
@@ -55,15 +52,6 @@ private:
 
 	AudioDriverCoreAudio audio_driver;
 
-#ifdef GAME_CENTER_ENABLED
-	GameCenter *game_center;
-#endif
-#ifdef STOREKIT_ENABLED
-	InAppStore *store_kit;
-#endif
-#ifdef ICLOUD_ENABLED
-	ICloud *icloud;
-#endif
 	iOS *ios;
 
 	JoypadIPhone *joypad_iphone;

+ 0 - 33
platform/iphone/os_iphone.mm

@@ -125,21 +125,6 @@ void OSIPhone::initialize() {
 }
 
 void OSIPhone::initialize_modules() {
-#ifdef GAME_CENTER_ENABLED
-	game_center = memnew(GameCenter);
-	Engine::get_singleton()->add_singleton(Engine::Singleton("GameCenter", game_center));
-#endif
-
-#ifdef STOREKIT_ENABLED
-	store_kit = memnew(InAppStore);
-	Engine::get_singleton()->add_singleton(Engine::Singleton("InAppStore", store_kit));
-#endif
-
-#ifdef ICLOUD_ENABLED
-	icloud = memnew(ICloud);
-	Engine::get_singleton()->add_singleton(Engine::Singleton("ICloud", icloud));
-#endif
-
 	ios = memnew(iOS);
 	Engine::get_singleton()->add_singleton(Engine::Singleton("iOS", ios));
 
@@ -154,24 +139,6 @@ void OSIPhone::deinitialize_modules() {
 	if (ios) {
 		memdelete(ios);
 	}
-
-#ifdef GAME_CENTER_ENABLED
-	if (game_center) {
-		memdelete(game_center);
-	}
-#endif
-
-#ifdef STOREKIT_ENABLED
-	if (store_kit) {
-		memdelete(store_kit);
-	}
-#endif
-
-#ifdef ICLOUD_ENABLED
-	if (icloud) {
-		memdelete(icloud);
-	}
-#endif
 }
 
 void OSIPhone::set_main_loop(MainLoop *p_main_loop) {

+ 1 - 2
platform/iphone/view_controller.h

@@ -28,13 +28,12 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#import <GameKit/GameKit.h>
 #import <UIKit/UIKit.h>
 
 @class GodotView;
 @class GodotNativeVideoView;
 
-@interface ViewController : UIViewController <GKGameCenterControllerDelegate>
+@interface ViewController : UIViewController
 
 @property(nonatomic, readonly, strong) GodotView *godotView;
 @property(nonatomic, readonly, strong) GodotNativeVideoView *videoView;

+ 1 - 10
platform/iphone/view_controller.mm

@@ -36,6 +36,7 @@
 #import "native_video_view.h"
 #include "os_iphone.h"
 
+#import <AVFoundation/AVFoundation.h>
 #import <GameController/GameController.h>
 
 @interface ViewController ()
@@ -214,14 +215,4 @@
 	}
 }
 
-// MARK: Delegates
-
-#ifdef GAME_CENTER_ENABLED
-- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController {
-	//[gameCenterViewController dismissViewControllerAnimated:YES completion:^{GameCenter::get_singleton()->game_center_closed();}];//version for signaling when overlay is completely gone
-	GameCenter::get_singleton()->game_center_closed();
-	[gameCenterViewController dismissViewControllerAnimated:YES completion:nil];
-}
-#endif
-
 @end