react-native-vision-camera: 🔧 V3.x FrameProcessorPlugin : Can't find the -swift.h file

How were you trying to build the app?

Hey,

I’m using XCode to build my IOS app with RN Xcode : 14.3 RN : 0.72.5 Vison Camera : 3.3.1

I had to re-write my own FrameProcessor after migration from 2.15 to 3.3.1 But I don’t understand how to solve my last problems

What I have

  1. An OCRFrameProcessor.switft file
import MLKit


@objc(OCRFrameProcessorPlugin)
public class OCRFrameProcessorPlugin: FrameProcessorPlugin {

  @objc public static func callback(_ frame: Frame!, withArgs _: [Any]!) -> Any! {

...

  }
}
  1. An OCRFrameProcessor.m file
#import <Foundation/Foundation.h>

#import "OCRFrameProcessor.h"
#if defined __has_include && __has_include("OCRFrameProcessor-Swift.h")
#import "OCRFrameProcessor-Swift.h"
#else
#import <OCRFrameProcessor/OCRFrameProcessor-Swift.h>
#endif

@implementation RegisterPlugins

    + (void) load {
        [FrameProcessorPluginRegistry addFrameProcessorPlugin:@"OCR"
                                              withInitializer:^FrameProcessorPlugin*(NSDictionary* options) {
            return [[OCRFrameProcessor alloc] init];
        }];
    }

@end

This is where my problems are

  • I don’t understand where and what should be the “-swift.h” file
  • I’ve created a OCRFrameProcessor.h file as following but it doesn’t help
#import <VisionCamera/FrameProcessorPlugin.h>
#import <VisionCamera/FrameProcessorPluginRegistry.h>

@interface RegisterPlugins : FrameProcessorPlugin

@end

I’m quite new with this, so any help would be appreciated, I wanted to update to 3.x for my project in order to use new cool features.

Thanks

Full build logs

Showing All Messages
/src/ios/OCRFrameProcessor/OCRFrameProcessor.m:7:9: 'OCRFrameProcessor/OCRFrameProcessor-Swift.h' file not found

Project dependencies

{
    "react": "18.2.0",
    "react-native": "0.72.5",
    "react-native-reanimated": "^3.5.4",
    "react-native-vision-camera": "^3.3.1",
    "react-native-worklets-core": "^0.2.2"
}

VisionCamera Version

3.3.1

Target platforms

iOS

Operating system

MacOS

Can you build the VisionCamera Example app?

No, I cannot build the Example app either

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

Let me know if those logs get called for you.

Ah shit my bad, I don’t have logs in there. Try adding a log line in FrameProcessorPluginRegistry.m to see if the addFrameProcessorPlugins func is actually being called.

I created a PR that will do that here: https://github.com/mrousavy/react-native-vision-camera/pull/2012

Hey - well the -Swift file should be <YourProjectName>-Swift.h, for VisionCamera it’s VisionCamera-Swift.h. For the example app it’d be VisionCameraExample-Swift.h.

But you can also register it manually, it doesn’t need to be in a +load method - it can also be in the app’s AppDelegate 😃