Skip to content
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

Register plugin outside of AppDelegate #1

Conversation

AnomalousLLC
Copy link

Maintains compatibility with Expo out of the box, without requiring prebuild or ejecting

@rkmackinnon
Copy link
Owner

rkmackinnon commented May 10, 2023

Hi @AnomalousLLC. This seems helpful, thanks. I don't use vision-camera-code-scanner on Expo right now so I'll take your word on it that the code works in that setup.

I tried compiling this branch on the example project in this repo just to test that it still works without Expo and it did work for a regular build, but it failed to compile when building with use_frameworks! :linkage => :static:

/Users/rkmackinnon/Development/vision-camera-code-scanner/ios/VisionCameraCodeScanner.m:4:9: fatal error: 'VisionCameraCodeScanner-Swift.h' file not found
#import "VisionCameraCodeScanner-Swift.h"
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

I just spent a while working with @bglgwyng to add support for use_frameworks! :linkage => :static back in to my fork after they pointed out that vision-camera-code-scanner 0.2.0 built fine under those conditions, so I would prefer not to merge this PR until it is updated not to cause a regression on that point.

Unfortunately, I don't know at the moment exactly how you might resolve this, but I'll spend a bit of time on it if you will and hopefully one of us will get there soon ;)

@AnomalousLLC
Copy link
Author

AnomalousLLC commented May 16, 2023

Hi, @rkmackinnon! Appreciate your review.

SWIFT_OBJC_INTERFACE_HEADER_NAME = "VisionCameraCodeScanner-Swift.h";

Seems the header isn't included by default when linking statically & needed to be manually defined.

Please try again with the AnomalousLLC:react-native-vision-camera_static branch & let me know if it resolves the issue.

Thanks

@rkmackinnon
Copy link
Owner

Hi @AnomalousLLC

Thanks for the update. I was able to do some more testing today. That branch got me part way there, but there seems to be a tricky naming convention for referencing that header depending on whether or not static linking is used. I was able to get it to work in both cases with an additional modification to VisionCameraCodeScanner.m. If there's a way to do it without the __has_include macro I think it would look nicer, but I'm happy to merge your PR if you include this change.

#import <Foundation/Foundation.h>

#import "VisionCameraCodeScanner.h"

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

@implementation RegisterPlugins

    + (void) load {
        [self registerPlugin:[[VisionCameraCodeScanner alloc] init]];
    }

@end

Cheers

@AnomalousLLC
Copy link
Author

Hi again, @rkmackinnon!

Good catch on the conditional import; just confirmed it's still working in EAS builds.

Should be ready to merge.

Cheers

@rkmackinnon rkmackinnon merged commit 4ad35aa into rkmackinnon:react-native-vision-camera-v3 May 19, 2023
@rkmackinnon
Copy link
Owner

Hi @AnomalousLLC

This is merged now. Thank you very much for your contribution.

I've also made a couple more minor commits to the podspec and to the example app to take advantage of your new auto-registration code. At some point when the underlying VisionCamera repo is further along on their Android updates for v3 I'll spend some more time incorporating those changes here.

@AnomalousLLC AnomalousLLC deleted the react-native-vision-camera-v3 branch May 19, 2023 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants