Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 1843ca7

Browse files
Can't find variable: TNSMLKitCameraViewDelegate #1078
1 parent 4eb1f5a commit 1843ca7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mlkit/mlkit-cameraview.ios.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ export abstract class MLKitCameraView extends MLKitCameraViewBase {
171171
abstract createSuccessListener(): any;
172172
}
173173

174-
@ObjCClass(TNSMLKitCameraViewDelegate)
175174
class TNSMLKitCameraViewDelegateImpl extends NSObject implements TNSMLKitCameraViewDelegate {
175+
public static ObjCProtocols = [];
176176
private owner: WeakRef<MLKitCameraView>;
177177
private resultCallback: (message: any) => void;
178178
private options?: any;
@@ -181,6 +181,10 @@ class TNSMLKitCameraViewDelegateImpl extends NSObject implements TNSMLKitCameraV
181181
private onSuccessListener: any;
182182

183183
public static createWithOwnerResultCallbackAndOptions(owner: WeakRef<MLKitCameraView>, callback: (message: any) => void, options?: any): TNSMLKitCameraViewDelegateImpl {
184+
// defer initialisation because the framework may not be available / used
185+
if (TNSMLKitCameraViewDelegateImpl.ObjCProtocols.length === 0 && typeof (TNSMLKitCameraViewDelegate) !== "undefined") {
186+
TNSMLKitCameraViewDelegateImpl.ObjCProtocols.push(TNSMLKitCameraViewDelegate);
187+
}
184188
let delegate = <TNSMLKitCameraViewDelegateImpl>TNSMLKitCameraViewDelegateImpl.new();
185189
delegate.owner = owner;
186190
delegate.options = options;

0 commit comments

Comments
 (0)