craftzdog / react-native-quick-base64

A fast base64 module for React Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-quick-base64.h file not found

ElectricCoffee opened this issue · comments

I can't build my iOS project due to the above error. Xcode claims the header file doesn't exist, and thus doesn't know what to do with it.

However, manually monkeypatching the import to instead say ../cpp/react-native-quick-base64.h seems to fix the build problem.

The error occurs in ios/QuickBase64.h and ios/QuickBase64.m

I can't build my iOS project due to the above error. Xcode claims the header file doesn't exist, and thus doesn't know what to do with it.

However, manually monkeypatching the import to instead say ../cpp/react-native-quick-base64.h seems to fix the build problem.

The error occurs in ios/QuickBase64.h and ios/QuickBase64.m

im experiencing the exact same issue.
are you using this with firebase by any chance?

I can't build my iOS project due to the above error. Xcode claims the header file doesn't exist, and thus doesn't know what to do with it.
However, manually monkeypatching the import to instead say ../cpp/react-native-quick-base64.h seems to fix the build problem.
The error occurs in ios/QuickBase64.h and ios/QuickBase64.m

im experiencing the exact same issue. are you using this with firebase by any chance?

I am. We use Firebase to handle third party login

@ElectricCoffee oh wow i only saw that you had a workaround.
Thanks i finally got '@react-native-firebase/app' to build in our project

Were you guys able to create a production build? Even though it builds fine on debug it throws this error on production build:

CompileC /Usersiapp/Library/Developer/Xcode/DerivedData/xxxxx-fiwbbtcvxiiydtaswonrnctxmkvu/Build/Intermediates.noindex/ArchiveIntermediates/xxxi/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/react-native-quick-base64.build/Objects-normal/arm64/QuickBase64.o /Users/xxxxp/actions-runner/_work/xxxxx_mobile/xxxxx_mobile/node_modules/react-native-quick-base64/ios/QuickBase64.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-quick-base64' from project 'Pods')

It seems that if you build for Android or iOS it generates artifacts that are getting through patch-package resulting in a huge patch file that wasn't properly working on CI builds.

Here's the patch-package patch that works, keep in mind that it must be applied on a "clean" install since the /node_modules/react-native-quick-base64 contains the artifacts from the builds. So remove the package first, reinstall and then apply the patch immediately. Spent 2 hours trying to find what tf was going on, it silently fails to apply the patch, patch-package won't complain....

react-native-quick-base64+2.0.5.patch

diff --git a/node_modules/react-native-quick-base64/ios/QuickBase64.h b/node_modules/react-native-quick-base64/ios/QuickBase64.h
index 20a7c03..39e185d 100644
--- a/node_modules/react-native-quick-base64/ios/QuickBase64.h
+++ b/node_modules/react-native-quick-base64/ios/QuickBase64.h
@@ -1,6 +1,6 @@
 #import <React/RCTBridgeModule.h>
 #import <React/RCTEventEmitter.h>
-#import "react-native-quick-base64.h"
+#import "../cpp/react-native-quick-base64.h"
 
 @interface QuickBase64 : NSObject <RCTBridgeModule>
 
diff --git a/node_modules/react-native-quick-base64/ios/QuickBase64.mm b/node_modules/react-native-quick-base64/ios/QuickBase64.mm
index c3fc9c2..49f5fef 100644
--- a/node_modules/react-native-quick-base64/ios/QuickBase64.mm
+++ b/node_modules/react-native-quick-base64/ios/QuickBase64.mm
@@ -1,7 +1,7 @@
 #import "QuickBase64.h"
 #import <React/RCTBridge+Private.h>
 #import <React/RCTUtils.h>
-#import "react-native-quick-base64.h"
+#import "../cpp/react-native-quick-base64.h"
 
 @implementation QuickBase64

Thanks everyone for the provided solutions.

I faced this issue when I added firebase to the project. If someone is using EAS Build, you can use expo build lifecycle hooks to solve this issue.
This is an example script:

// Only run the script for iOS
if (process.env.EAS_BUILD_PLATFORM !== 'ios') {
  return;
}

// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');

// path is relative to package.json
const file1 = './node_modules/react-native-quick-base64/ios/QuickBase64.h';
const file2 = './node_modules/react-native-quick-base64/ios/QuickBase64.mm';

replaceImportStatementInFile(file1);
replaceImportStatementInFile(file2);

function replaceImportStatementInFile(filePath) {
  const searchString = '#import "react-native-quick-base64.h"';
  const replacementString = '#import "../cpp/react-native-quick-base64.h"';

  fs.readFile(filePath, 'utf8', (err, data) => {
    if (err) {
      console.error('Error reading the file:', err);
      return;
    }

    const updatedData = data.replace(searchString, replacementString);
    const tempFile = `${filePath}.tmp`;

    fs.writeFile(tempFile, updatedData, 'utf8', (err) => {
      if (err) {
        console.error('Error writing to temporary file:', err);
        return;
      }

      fs.rename(tempFile, filePath, (err) => {
        if (err) {
          console.error('Error renaming the file:', err);
          return;
        }

        console.log(`Replacement completed!: ${filePath}`);
      });
    });
  });
}

@craftzdog When will this change be live on npm?