diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-11-20 21:17:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 21:17:43 +0100 |
commit | 719254ae0d4e1b7c9be36a4399809caf270d7e86 (patch) | |
tree | d09eb24766ac2938f1cd006c1d4cc7401711f8a2 | |
parent | ccebd1f4fc04e7748308c991068516ecd4e0e66f (diff) | |
parent | a9fef1a77442297d8c95d9346ee8a1b0341a4049 (diff) |
Merge pull request #33759 from bruvzg/arkit_dyn_load
[iOS] Link and load ARKit framework dynamically.
-rw-r--r-- | modules/arkit/arkit_interface.mm | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/modules/arkit/arkit_interface.mm b/modules/arkit/arkit_interface.mm index 9614f775a5..71642cfc30 100644 --- a/modules/arkit/arkit_interface.mm +++ b/modules/arkit/arkit_interface.mm @@ -37,6 +37,8 @@ #import <ARKit/ARKit.h> #import <UIKit/UIKit.h> +#include <dlfcn.h> + #include "arkit_interface.h" #include "arkit_session_delegate.h" @@ -53,7 +55,10 @@ void ARKitInterface::start_session() { // Ignore this if we're not initialized... if (initialized) { print_line("Starting ARKit session"); - ARWorldTrackingConfiguration *configuration = [ARWorldTrackingConfiguration new]; + + Class ARWorldTrackingConfigurationClass = NSClassFromString(@"ARWorldTrackingConfiguration"); + ARWorldTrackingConfiguration *configuration = [ARWorldTrackingConfigurationClass new]; + configuration.lightEstimationEnabled = light_estimation_is_enabled; if (plane_detection_is_enabled) { configuration.planeDetection = ARPlaneDetectionVertical | ARPlaneDetectionHorizontal; @@ -221,7 +226,17 @@ bool ARKitInterface::initialize() { print_line("initializing ARKit"); // create our ar session and delegate - ar_session = [ARSession new]; + Class ARSessionClass = NSClassFromString(@"ARSession"); + if (ARSessionClass == Nil) { + void *arkit_handle = dlopen("/System/Library/Frameworks/ARKit.framework/ARKit", RTLD_NOW); + if (arkit_handle) { + ARSessionClass = NSClassFromString(@"ARSession"); + } else { + print_line("ARKit init failed"); + return false; + } + } + ar_session = [ARSessionClass new]; ar_delegate = [ARKitSessionDelegate new]; ar_delegate.arkit_interface = this; ar_session.delegate = ar_delegate; |