-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: NativeClass #1
Comments
Any idea what could be the reason and how to fix it? |
You've declared a Nativeclass but you should do some setup in ordre to get it worked, mainly you need to install ts-patch as dev dependencies and add this to your tsconfig.json "plugins": [{
"transform": "@nativescript/webpack/transformers/ns-transform-native-classes",
"type": "raw"
}] and when building the plugin you should run this // package.json
// scripts
"build": "npm run clean && ts-patch install && tsc"
// npm run build && npm run demo.ios |
I think that the error come from the build command that doesn't include the |
After a quick review, you declare you delegate directly at your class, I think It will be necessary to implement another class that implements location manager then use it into your main class, see here a full example @NativeClass
class CLLocationManagerDelegateImpl extends NSObject implements CLLocationManagerDelegate {
public static ObjCProtocols = [CLLocationManagerDelegate];
public _owner: WeakRef<GGMLocationMnager>;
public static initWithOwner(owner: WeakRef<GGMLocationMnager>): CLLocationManagerDelegateImpl {
let handler = CLLocationManagerDelegateImpl.new() as CLLocationManagerDelegateImpl;
handler._owner = owner
console.log("CLLocationManagerDelegateImpl:initWithOwner")
return handler;
}
public locationManagerDidChangeAuthorization(cclm: CLLocationManager) {
let owner = this._owner.get();
console.log("CLLocationManagerDelegateImpl:locationManagerDidChangeAuthorization")
owner.requestAlwaysAuthorization()
console.log(cclm.location)
}
public locationManagerDidUpdateLocations(manager: CLLocationManager, locations: NSArray<CLLocation> | CLLocation[]): void {
let owner = this._owner.get();
console.log("CLLocationManagerDelegateImpl:locationManagerDidUpdateLocations")
console.log(locations)
}
public locationManagerDidUpdateToLocationFromLocation(manager: CLLocationManager, newLocation: CLLocation, oldLocation: CLLocation): void {
let owner = this._owner.get();
console.log("CLLocationManagerDelegateImpl:locationManagerDidUpdateToLocationFromLocation")
console.log(newLocation)
}
} |
Thanks @kefahB , For the pointer, I have made the changes, However while building, i'm getting below error. FYI.. tried with deleting package-lock.json file and installing the npm freshly. any idea how can i fix it? Nativescript version -8.0.2 |
This error come from build.native… go to src/scripts/build-native.js and keep just this code: ´´´ts const { exec } = require('child_process'); exec('tns plugin build', (err, stdout, stderr) => { ´´´ |
thank you so much for your help @kefahB . The above error is resolved now. However, when i say 'ns prepare ios' getting below error. any idea about it? |
Hello @kefahB , The above issue is gone now. However when i run the app on simulator, it just crash with below error. Have you ever seen this before? any pointer on this would be really helpful. |
2022-02-07 14:04:59.382128+0530 DS22110Loc[28232:228967] ***** Fatal JavaScript exception - application has been terminated. *****
2022-02-07 14:04:59.382253+0530 DS22110Loc[28232:228967] Native stack trace:
2022-02-07 14:04:59.389492+0530 DS22110Loc[28232:228967] 1 0x11151162e NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
1 0x11151162e NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
2022-02-07 14:04:59.389731+0530 DS22110Loc[28232:228967] 2 0x111563524 -[TNSRuntime executeModule:referredBy:]
2 0x111563524 -[TNSRuntime executeModule:referredBy:]
2022-02-07 14:04:59.390140+0530 DS22110Loc[28232:228967] 3 0x10e15da8f main
3 0x10e15da8f main
2022-02-07 14:04:59.390313+0530 DS22110Loc[28232:228967] 4 0x10eb22e1e
4 0x10eb22e1e
2022-02-07 14:04:59.390460+0530 DS22110Loc[28232:228967] 5 0x114ba64fe
5 0x114ba64fe
2022-02-07 14:04:59.390564+0530 DS22110Loc[28232:228967] JavaScript stack trace:
2022-02-07 14:04:59.390723+0530 DS22110Loc[28232:228967] ./node_modules/nativescript-scheduled-location-update/scheduled-location-update.ios.js(file:///app/vendor.js:112820:16)
at webpack_require(file:///app/runtime.js:23:46)
at ./app/App_Delegates/CustomAppDelegate.ts(file:///app/bundle.js:247:115)
at webpack_require(file:///app/runtime.js:23:46)
at ./app/app.ts(file:///app/bundle.js:158:48)
at webpack_require(file:///app/runtime.js:23:46)
at webpack_exec(file:///app/bundle.js:7906:58)
at file:///app/bundle.js:7907:237
at file:///app/runtime.js:114:23
at file:///app/bundle.js:7907:48
at anonymous(file:///app/bundle.js:7912:3)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([native code])
at [native code]
at promiseReactionJob([native code])
2022-02-07 14:04:59.392505+0530 DS22110Loc[28232:228967] JavaScript error:
2022-02-07 14:04:59.393266+0530 DS22110Loc[28232:228967] file:///app/vendor.js:112820:16: JS ERROR ReferenceError: Can't find variable: NativeClass
file:///app/vendor.js:112820:16: JS ERROR ReferenceError: Can't find variable: NativeClass
2022-02-07 14:04:59.395600+0530 DS22110Loc[28232:228967] *** JavaScript call stack:
(
)
2022-02-07 14:04:59.395777+0530 DS22110Loc[28232:228967] *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: NativeClass
at
./node_modules/nativescript-scheduled-location-update/scheduled-location-update.ios.js(file:///app/vendor.js:112820:16)
at webpack_require(file:///app/runtime.js:23:46)
at ./app/App_Delegates/CustomAppDelegate.ts(file:///app/bundle.js:247:115)
at webpack_require(file:///app/runtime.js:23:46)
at ./app/app.ts(file:///app/bundle.js:158:48)
at webpack_require(file:///app/runtime.js:23:46)
at webpack_exec(file:///app/bundle.js:7906:58)
at file:///app/bundle.js:7907:237
at file:///app/runtime.js:114:23
at file:///app/bundle.js:7907:48
at anonymous(file:///app/bundle.js:7912:3)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([native code])
at [native code]
at promiseReactionJob([native code])
', reason: '(null)'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff203fbbb4 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff2019ebe7 objc_exception_throw + 48
2 NativeScript 0x0000000111511b6f _ZN12NativeScript30reportFatalErrorBeforeShutdownEPN3JSC9ExecStateEPNS0_9ExceptionEb + 1631
3 NativeScript 0x0000000111563524 -[TNSRuntime executeModule:referredBy:] + 660
4 DS22110Loc 0x000000010e15da8f main + 159
5 dyld 0x000000010eb22e1e start_sim + 10
6 ??? 0x0000000114ba64fe 0x0 + 4642727166
)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/ajitesh/Library/Developer/Xcode/DerivedData/DS22110Loc-asmecbiasoutamdmbpurlvaqtbqw/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/ajitesh/Library/Developer/Xcode/DerivedData/DS22110Loc-asmecbiasoutamdmbpurlvaqtbqw/Build/Products/Debug-iphonesimulator
*** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: NativeClass
at
./node_modules/nativescript-scheduled-location-update/scheduled-location-update.ios.js(file:///app/vendor.js:112820:16)
at webpack_require(file:///app/runtime.js:23:46)
at ./app/App_Delegates/CustomAppDelegate.ts(file:///app/bundle.js:247:115)
at webpack_require(file:///app/runtime.js:23:46)
at ./app/app.ts(file:///app/bundle.js:158:48)
at webpack_require(file:///app/runtime.js:23:46)
at webpack_exec(file:///app/bundle.js:7906:58)
at file:///app/bundle.js:7907:237
at file:///app/runtime.js:114:23
at file:///app/bundle.js:7907:48
at anonymous(file:///app/bundle.js:7912:3)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([native code])
at [native code]
at promiseReactionJob([native code])
', reason: '(null)'
terminating with uncaught exception of type NSException
CoreSimulator 776.3 - Device: iPad Pro (11-inch) (3rd generation) (F19BBC1C-819E-4B0F-AE52-77DCEAF64093) - Runtime: iOS 15.0 (19A339) - DeviceType: iPad Pro (11-inch) (3rd generation)
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/ajitesh/Library/Developer/Xcode/DerivedData/DS22110Loc-asmecbiasoutamdmbpurlvaqtbqw/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/ajitesh/Library/Developer/Xcode/DerivedData/DS22110Loc-asmecbiasoutamdmbpurlvaqtbqw/Build/Products/Debug-iphonesimulator
*** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: NativeClass
at
./node_modules/nativescript-scheduled-location-update/scheduled-location-update.ios.js(file:///app/vendor.js:112820:16)
at webpack_require(file:///app/runtime.js:23:46)
at ./app/App_Delegates/CustomAppDelegate.ts(file:///app/bundle.js:247:115)
at webpack_require(file:///app/runtime.js:23:46)
at ./app/app.ts(file:///app/bundle.js:158:48)
at webpack_require(file:///app/runtime.js:23:46)
at webpack_exec(file:///app/bundle.js:7906:58)
at file:///app/bundle.js:7907:237
at file:///app/runtime.js:114:23
at file:///app/bundle.js:7907:48
at anonymous(file:///app/bundle.js:7912:3)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([native code])
at [native code]
at promiseReactionJob([native code])
', reason: '(null)'
terminating with uncaught exception of type NSException
CoreSimulator 776.3 - Device: iPad Pro (11-inch) (3rd generation) (F19BBC1C-819E-4B0F-AE52-77DCEAF64093) - Runtime: iOS 15.0 (19A339) - DeviceType: iPad Pro (11-inch) (3rd generation)
NS doctor output

The text was updated successfully, but these errors were encountered: