GVR Audio Renderer not found iOS - ios

I am tinkering with the sample project "SpatialAudio" from Google VR SDK for Unity, to implement it in iOS.
I built it in Unity using the latest GVR SDK, so I had to replace a few deprecated keywords (GvrAudioSource instead of CardboardAudioSource, etc.)
If I build it in Xcode just as Unity gives it to me, it runs fine in the physical device.
Then, I tried to edit the Unity-generated file 'main.mm' to change the default App Controller (UnityAppController) to a new one, let's call it NewAppController.
// main.mm
...
const char* AppControllerClassName = "UnityAppController";
...
//UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String:AppControllerClassName]); // old
UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String:"NewAppController"]); // new
NewAppController is a class which inherits from UnityAppController and does not override any of its methods or properties, like this:
#interface NewAppController : UnityAppController
#end
#implementation NewAppController
#end
I thought that it should work exactly the same as before, but now I get the following warning in runtime:
"Audio effect GVR Audio Renderer could not be found. Check that the project contains the correct native audio plugin libraries and that the importer settings are set up correctly."
Everything else works just fine: I can see the video and even hear the sounds, but only they are not 'spatialized'.
I am using:
GVR SDK 1.1,
Unity 5.5.0f3,
iOS 10.1.1

I found the solution. I was missing two important things: First, messing with main.mm causes a lot of trouble. The correct approach for defining a custom App Controller is to create a subclass of UnityAppController and adding the macro IMPL_APP_CONTROLLER_SUBCLASS(name_of_the_class) at the bottom of its .mm file. Second, Unity automatically generates a custom app controller, called CardboardAppController, which is located in the build directory, under 'Libraries/Plugins/iOS'. One of its functions is registering the unity audio effect plugin. I was bypassing this file without knowing, causing the audio renderer to not initialize properly. So my solution was to comment out the macro at the end of the file CardboardAppController.mm (line 71):
//IMPL_APP_CONTROLLER_SUBCLASS(CardboardAppController)
And defining the new custom controller as a subclass of CardboardAppController:
#import "CardboardAppController.h"
#interface NewAppController : CardboardAppController
#end
#implementation NewAppController
#end
IMPL_APP_CONTROLLER_SUBCLASS(NewAppController)

Related

My custom native module is not present inside NativeModules object

So, i wanted to create a native module which will detect, if the app is running on emulator/simulator or an actual device.
Everything works fine on android, but i'm facing issue on iOS.
I have create a AbcModule.h and a AbcModule.m file
#import <React/RCTBridgeModule.h>
#interface AbcModule : NSObject <RCTBridgeModule>
#end
This is AbcModule.h
#import "AbcModule.h"
#implementation AbcModule
RCT_EXPORT_MODULE(GetDetails);
- (BOOL) xyzFunctn {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
return NO;
#endif
}
RCT_EXPORT_METHOD(xyzFunctn: (RCTPromiseResolveBlock)resolve rejecter: (RCTPromiseRejectBlock)reject) {
resolve self.xyzFunctn;
}
#end
This is AbcModule.m
Here i have followed the react native documentation for implementing the Native Modules.
But i'm consistently facing this error which says
"TypeError null is not an object, evaluating GetDetails.xyzFunctn"
I have went through several solutions and articles but nothing seems to be working here.
Need help guys!
from the docs
If you do not specify a name, the JavaScript module name will match the Objective-C class name, with any "RCT" or "RK" prefixes removed.
so just do not specify any name,
#implementation AbcModule
// To export a module named AbcModule
RCT_EXPORT_MODULE();
#end
in your case it should then be accessible from within JS with
AbcModule
But the documentation is not clear if the Objective-C Class declaration needs to be written with prefixed "RCT" or "RK".. but because both prefixes seem to be valid, you should be able to just use AbcModule without prefix.
In other words, if you want to use GetDetails from within JS you need to name your interface and implementation accordingly
#implementation RCTGetDetails
RCT_EXPORT_MODULE(GetDetails);
// or
// RCT_EXPORT_MODULE();
#end
Okay, if there is someone who is facing this issue and feels like their code should work but it isn't and any solution online not working for you as well.
Try this:
When you create your .h and .m file for header and objective-c or swift file, make sure you do it in Xcode and not from VSCode.
VSCode eventually doesn't adds you .h file in the required resources folder, i have wasted my 2 weeks trying to find out solution for it, but lastly, that was it, yes this is it.
in your .m file, let's say GetDetails is a class of NSObject .swift
you need:
#interface RCT_EXTERN_MODULE(WidgetManager, NSObject)
// method to export
RCT_EXTERN_METHOD(isAuthenticated: (BOOL *)isAuthenticated)
#end
in your GetDetails.swift:
#objc(GetDetails)
class GetDetails: NSObject {
#objc(isAuthenticated:)
func isAuthenticated(_ isAuthenticated: Bool) {
}
}

How to set PT_DENY_ATTACH in Xamarin.iOS?

We recently had a pen tester audit our app and one of the findings was that a person with a jailbroken device can attach a local debugger.
The solution they suggested was to enable PT_DENY_ATTACH when starting up the app. This is fairly easy to do in a native app but I haven't been able to figure it out with our Xamarin app (not forms).
I've tried creating an objc framework in Xcode, binding that and pulling it in. I've also tried to create a shared c++ library but that isn't possible in VS Mac.
I know that PT_DENY_ATTACH has been circumvented but I'd still like to know how to implement it.
Thanks!
It turns out that my objc framework was behaving properly just not in the way I expected. For some reason I was still able to attach the Visual Studio debugger but when I move to Xcode and try to attach its debugger it fails when the framework is called.
To answer my question:
In Xcode I created a new static library with one class:
GDBManager.h
#import <Foundation/Foundation.h>
#interface GDBManager : NSObject
+(void)DisableGDB;
#end
GDBManager.m
#import "GDBManager.h"
#import <dlfcn.h>
#import <sys/types.h>
#implementation GDBManager
typedef int (*ptrace_ptr_t)(int _request, pid_t _pid, caddr_t _addr, int _data);
#define PT_DENY_ATTACH 31
+(void)DisableGDB {
void* handle = dlopen(0, RTLD_GLOBAL | RTLD_NOW);
ptrace_ptr_t ptrace_ptr = dlsym(handle, "ptrace");
ptrace_ptr(PT_DENY_ATTACH, 0, 0, 0);
dlclose(handle);
}
#end
I followed these instructions to create a fat file for my library and to use that in a binding project.
https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/walkthrough
I then add the generated dll to my Xamarin.iOS project and call it above UIApplication.Main(args, null, "AppDelegate"); in Main.cs

How to Implement native module in react-native?

I am following this guide
http://facebook.github.io/react-native/docs/nativemodulesios.html#content
And also this website:
http://colinramsay.co.uk/2015/03/27/react-native-simple-native-module.html
But does not matter where i add the .h and .m files i always get the error:
Class ClassName was not exported Did you forget to use RTC_EXPORT_MODULE()?
Even if it the same code from the examples from react-native documentation, can anyone guide me where to add the .h and .m files and properly link them to the project?
Thanks.
There has been a change in the native module API and it seems the docs haven't been updated accordingly. From the example in my article, SomeString.m should look like this:
// SomeString.m
#import "SomeString.h"
#implementation SomeString
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(get:(RCTResponseSenderBlock)callback)
{
// Change this depending on what you want to retrieve:
NSString* someString = #"something";
callback(#[someString]);
}
#end
This ends up with the desired result and you can call it from JS in the same way as before. It looks like this only just happened:
https://github.com/facebook/react-native/commit/0686b0147c8c8084e4a226b7ea04585362eccea8
You can also just add a plain RCT_EXPORT(); to any method you want to export. Works like a charm.

Vector file not found in Metaio cloud plugin viewcontroller

I have installed a Metaio SDK in my IOS app and currently i am getting an error in the MetaioCloudPluginViewController.h that the vector file is not found, i have tried to change the type from .m or .mm where i have used this sdk file but unfortunately if i would do it then the new errors are popping up such as "comparison between pointer and integer". I have changed few things in my build setting but still the result is same.
This the file which i am including in the stated viewcontroller.
#include <vector>
The below code is used in one of the viewcontroller.m file.
- (IBAction)onStartPushed:(id)sender {
// Create a new ARViewController. All channel details and properties are defined in that class.
// see ARViewController.mm for the implementation
ARViewController* metaioCloudPlugin = [[ARViewController alloc] init];
// present the viewcontroller
[self presentViewController:metaioCloudPlugin animated:YES completion:nil];
// release it, because it's retained as modalViewController
//[metaioCloudPlugin release];
}
Thanks for your time.
You need to rename your viewcontroller.m to viewcontroller.mm file because there is a C++ code.
Hope this helps.

I "fixed" Apple's "QA:1702:How to capture video frames ... using AV Foundation." Why does an ivar work?

Apple's "QA:1702:How to capture video frames from the camera as images using AV Foundation" is "broken"without additional ivar code.
I found a fix - but what is an ivar and what is it doing in this case?
Here is the code that has to be added to Apple's TestAVViewController.h file:
#interface TestAVViewController : UIViewController <AVCaptureVideoDataOutputSampleBufferDelegate>
#property AVCaptureSession *session;
#end
Here is the code that must be added to Apple's TestAVViewController.m file:
#implementation TestAVViewController
#synthesize session=ivarSession; // this creates an ivar
By adding both of those sections (which Apple does not provide), the following line will stop throwing a compilation error:
[self setSession:session];
What is the "session = ivarSession" doing that is preventing the compilation error? Why does it make Apple's code work?
The code you added creates and initializes a member variable.
Are you sure you copied the code correctly? The version I'm looking at on the page you linked to has session defined and initialized at the top of the - (void)setupCaptureSession message and that is the only message it is used in. This really should be a local variable, not a member variable.

Resources