Skip to content

Fix iOS crash from Dynamsoft setCameraView nullable NSNumber signature #58

@stealkiller06

Description

@stealkiller06

Details

The app crashes/logs a React Native bridge argument error on iOS when initializing the VIN barcode scanner with Dynamsoft:

Argument 0 (NSNumber) of DynamsoftCameraView.setCameraView is marked as nullable but React requires that all NSNumber arguments are explicitly marked as `nonnull` to ensure compatibility with Android.

This happens because dynamsoft-capture-vision-react-native@3.4.1100 exports the iOS native method as:

RCT_EXPORT_METHOD(setCameraView:(nullable NSNumber *)tag)

React Native 0.79.7 validates native module method signatures in debug mode and rejects nullable NSNumber arguments. RN requires NSNumber arguments to be explicitly marked as nonnull for Android compatibility.

The JS wrapper already avoids passing native null into this method. When CameraEnhancer.setCameraView(null) is called from JS, Dynamsoft translates it to:

DynamsoftCameraEnhancerModule.setCameraView(0);

So the native method contract is already effectively non-null, using 0 as the sentinel value to clear/unbind the camera view.

Proposed Fix

Patch dynamsoft-capture-vision-react-native so the iOS native export changes from:

RCT_EXPORT_METHOD(setCameraView:(nullable NSNumber *)tag)

to:

RCT_EXPORT_METHOD(setCameraView:(nonnull NSNumber *)tag)

No app-level JS changes are required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions