NativeScript iOS Delegate Transpilation error (Can't find variable: __metadata) - ios

I'm attempting to implement an iOS delegate in a NativeScript plugin and am getting an error:
Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: __metadata
My original code is:
#ObjCClass(SQRDCheckoutControllerDelegate)
export class SquareReader extends NSObject implements SQRDCheckoutControllerDelegate {
/*
iOS delegate implementation here
(source https://docs.connect.squareup.com/payments/readersdk/setup-ios)
*/
}
And that's getting transpiled in js down to:
SquareReader = __decorate([
ObjCClass(exports.SQRDCheckoutControllerDelegate),
__metadata("design:paramtypes", [])
], SquareReader);
If I just remove the __metadata line, I get a different error:
Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Error: Protocol "undefined" is not a protocol object.
Any ideas? I've seen other examples like nativescript-image-swipe where the code is being transpiled w/o the __metadata method leading me to think something might be wrong with the transpilation

I solved this by cleaning up my typings. I just re-ran the command to generate typings: TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios and put them in my /src directory for my plugin. Once my typings were correct the project ran as expected and the Delegate worked

Related

AKMicrophone causes SIGABRT error - A bug?

I found a post that has the same error in the same situation here:
https://groups.google.com/forum/#!topic/audiokit/SmyuzPJQ6wU
Same as this poster - I'm using the source. However, at the end of the post the user does not say what he did to fix the issue.
I'm currently using an unaltered "ExtendingAudioKitUsingSource" example as I need to add some functionality to audiokit. (unaltered outside of using my provisioning profile and adding "let m = AKMicrophone()" in ViewController.swift.
I receive these errors:
2018-08-31 15:16:50.684 ExtendingAudioKit[6800:8850964] 15:16:50.683
ERROR: [0x39058000] AVAudioIONodeImpl.mm:452:
___ZN13AVAudioIOUnit9EnableBusEm_block_invoke: error -10849
2018-08-31 15:16:50.688 ExtendingAudioKit[6800:8850964] ***
Terminating app due to uncaught exception
'com.apple.coreaudio.avfaudio', reason: 'error -10849'
which traces back to line 46 in AKMicrophone.swift to init(): AudioKit.engine.connect(AudioKit.engine.inputNode, to: self.avAudioNode, format: nil)
I've had no issues using AKMicrphone() outside of this project.
I have fixed an AKMicrophone bug in AudioKit v4.5.1 that may have fixed this for you. If not, I'll withdraw this answer, but please check it out and let me know.

Error: global.nativeTraceBeginSection is not a function

I didnt change anything but suddenly I got this error in my xproject and the app got stuck and thing the when I do simulator through my Xcode is working but not with physical device.
the full log is here:
'Failed to print error: ', 'global.nativeTraceBeginSection is not a function. (In \'global.nativeTraceBeginSection(TRACE_TAG_REACT_APPS, profileName, args)\', \'global.nativeTraceBeginSection\' is undefined)'
WARNING: Logging before InitGoogleLogging() is written to STDERR
E0910 19:37:09.077337 1871998976 JSCHelpers.cpp:137] Got JS Exception: Exception calling object as function: global.nativeTraceEndSection is not a function. (In 'global.nativeTraceEndSection(TRACE_TAG_REACT_APPS)', 'global.nativeTraceEndSection' is undefined) (<unknown file>:2303)
E0910 19:37:09.077525 1871998976 JSCHelpers.cpp:143] Got JS Stack: endEvent#http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:2303:35
__callFunction#http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:2098:24
http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:1927:29
__guard#http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:2068:11
callFunctionReturnFlushedQueue#http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:1926:19
callFunctionReturnFlushedQueue#[native code]
2018-09-10 19:37:09.079 [fatal][tid:com.facebook.react.JavaScript] Error calling Systrace.setEnabled
Unhandled JS Exception: Exception calling object as function: global.nativeTraceEndSection is not a function. (In 'global.nativeTraceEndSection(TRACE_TAG_REACT_APPS)', 'global.nativeTraceEndSection' is undefined) (<unknown file>:2303)
2018-09-10 19:37:09.082 [error][tid:com.facebook.react.JavaScript] global.nativeTraceBeginSection is not a function. (In 'global.nativeTraceBeginSection(TRACE_TAG_REACT_APPS, profileName, args)', 'global.nativeTraceBeginSection' is undefined)
2018-09-10 19:37:09.083 [info][tid:com.facebook.react.JavaScript] 'Failed to print error: ', 'Can\'t find variable: regeneratorRuntime'
E0910 19:37:09.086755 1871998976 JSCHelpers.cpp:137] Got JS Exception: Exception calling object as function: global.nativeTraceBeginSection is not a function. (In 'global.nativeTraceBeginSection(TRACE_TAG_REACT_APPS, profileName, args)', 'global.nativeTraceBeginSection' is undefined) (<unknown file>:2298)
E0910 19:37:09.086828 1871998976 JSCHelpers.cpp:143] Got JS Stack: beginEvent#http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:2298:37
__invokeCallback#http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:2125:28
http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:1950:32
__guard#http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:2068:11
invokeCallbackAndReturnFlushedQueue#http://192.168.1.27.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false:1949:19
invokeCallbackAndReturnFlushedQueue#[native code]
(lldb)
I have been trying to find solution, didn't succeed with any of them.
this error shows on my Xcode logged and not on my screen of the phone
Thank you so much for the help!!
I had the same issue because I unintentionally enabled Start Systrace and since it is a known react native issue... I was getting the error.
What worked for me was just disabling Start Systrace and restarting the project. How I do that?
Command ⌘ + D
Press Disable Start Systrace, that's it!
This is a known, unresolved React Native issue. There are a few workarounds in the GitHub issue, including:
Delete, and then reinstall the app from Xcode or react-native run-ios
Revert to the old bridge (instructions)
See https://github.com/facebook/react-native/issues/15003 for more details.

React Native - RCTFatalException: Unhandled JS Exception: "version" is a required argument

I'm doing a React Native App
(react-native: 0.43.4)
And I'm having problems on running Release schema on iOS.
I have Pods (Crashlytics) and I'm running my app through the Workspace Project.
On Debug schema it runs without a problem, when I switch to Release it throws this exception:
*** Terminating app due to uncaught exception 'RCTFatalException:
Unhandled JS Exception: "version" is a required argument.',
reason: 'Unhandled JS Exception: "version" is a required argument., stack:
a#551:111
i#550:244
o#550:143
l#543:504
<unknown>#381:901
<unknown>#381:676
<unknown>#381:851
<unknown>#381:676
go#381:525
<unknown>#381:651
<unknown>#381:651
<unknown>#381:651
<unknown>#381:651
<unknown>#12:741
i#2:965
t#2:572
global code#667:9
'
*** First throw call stack:
(0x18f35efd8 0x18ddc0538 0x18f35ef20 0x1000e3010 0x1000dd54c 0x18f364e80 0x18f25a2b4 0x18f25ee7c 0x1000e0f6c 0x100106e0c 0x1001067bc 0x1005f1a50 0x1005f1a10 0x1005ff2e8 0x1005f5634 0x1005ff810 0x100601630 0x10060139c 0x18e41f1d0 0x18e41ed7c)
libc++abi.dylib: terminating with uncaught exception of type NSException
I've been searching this exception although I haven't find a solution yet...
Any clue what this is?
Thank you.
Your error comes from your javascript
Unhandled JS Exception
Since it's happening only on release mode, check any js code that is executed only in that mode (for example, search for any if (!__DEV__) or other flags you might use to distinguish between release and debug mode)

IOS Google OAuth error occured after 1 success authentication

I was trying to make a Google authentication with swift to get message list. However i follow all steps in Google here
after i run in simulator and success logging in to my account authentication was successful. then problem appears after all success which is weird. does any knows how to fix this?
selector "displayResultWithTicket:finishedWithObject:error:" is unimplemented or misnamed
Assertion failure in void GTMSessionFetcherAssertValidSelector(id _Nullable __strong, SEL _Nullable, ...)(), /Users/macbookpro/Documents/Zaiya/Pods/GTMSessionFetcher/Source/GTMSessionFetcher.m
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'callback selector unimplemented or misnamed'
please share your knowledge, thanks!
actual run error:
I ran into the same problem. I believe it's because Google hasn't updated the Quickstart for Swift 3 yet.
Change:
displayResultWithTicket:finishedWithObject:error: to #selector([Your View Controller Name Here].displayResultWithTicket(ticket:finishedWithObject:error:)), which is in line with the new Swift 3 syntax

iOS 64bit #try {... } #catch {...} not working

I have a very peculiar issue.
Recently I added 64bit support to my iOS project (arm64), ever since doing that I started receiving uncaught exceptions for segments of my code inside #try...#catch (I'm using Crashlytics for crash reporting). I managed to reproduce the problem with the following lines of code anywhere in my app (I wrote them inside init of one of my view controllers):
#try {
NSMutableDictionary *m = [[NSMutableDictionary alloc] init];
NSString *s;
m[s] = #"poop";
} #catch (NSException *e) {
NSLog(#"POOP");
}
The exception gets caught by the UncaughtExceptionHandler instead of the #catch clause. I'm confused as to what can cause this. The output in the console:
2015-02-22 19:19:53.525 [391:30650] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
*** First throw call stack:
(0x18823a59c 0x1989400e4 0x1881251f8 0x10011e2f4 0x10011e068 0x10010e480 0x10010db78 0x10010d944 0x1000a8050 0x100075d88 0x100075160 0x100142044 0x100141f6c 0x18c9ecaa0 0x18caa1fb4 0x18caa1eb0 0x18caa134c 0x18caa0ff8 0x18caa0d18 0x18caa0c98 0x18c9e9648 0x18c341994 0x18c33c564 0x18c33c408 0x18c33bc08 0x18c33b98c 0x18cc76dbc 0x18cc77c68 0x18cc75dec 0x1904b162c 0x1881f2a28 0x1881f1b30 0x1881efd30 0x18811d0a4 0x18ca573c8 0x18ca523c0 0x1000747d8 0x198faea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
I tried removing the custom exception handler that I have and disabling Crashlytics, still no success.
As soon as I remove arm64 from ARCHS and VALID_ARCHS the code works and the exception is caught as expected.
Any information will be appreciated!
Small update - our XCTests also started not to catch exceptions, up until now the behaviour only happened on physical 64bit phones.
After a long session of git-bisecting the culprit was the following linker flag
-no_compact_unwind
I Used BlocksKit v2.2.0 which still had that flag even though it stopped using libffi (latest version of BlocksKit removed that unneeded flag). As soon as I removed that linker flag 64bit #try...#catch blocks started to work again.
I still don't have complete understanding of why this behaviour happens but I'm going to dig a bit more and update this thread if I find anything interesting.
phew
On iOS and Objective-C Exceptions are only to be used for un-recoverable programming errors, not for program execution control.
In particular they do not handle catches accross stack frames inthe APIs.

Resources