chargebee / chargebee-react-native

MIT License
8 stars 15 forks source link

'ChargebeeReactNative-Swift.h' file not found #178

Closed kylea3 closed 1 month ago

kylea3 commented 2 months ago

Hi, I added "@chargebee/react-native-chargebee": "^2.4.5" to my project and now all builds fail with the the following error:

node_modules/@chargebee/react-native-chargebee/ios/ChargebeeReactNative.mm:2:9)

1 | #import "ChargebeeReactNative.h"

2 | #import | ^ 'ChargebeeReactNative-Swift.h' file not found 3 | 4 | @implementation ChargebeeReactNative 5 | RCT_EXPORT_MODULE() The following build commands failed: ▸ CompileC /Users/expo/Library/Developer/Xcode/DerivedData/Tallio-bbielmlrqyffaodyqcvcjhdlhgly/Build/Intermediates.noindex/ArchiveIntermediates/Tallio/IntermediateBuildFilesPath/Pods.build/Debug-iphoneos/ChargebeeReactNative.build/Objects-normal/arm64/ChargebeeReactNative.o /Users/expo/workingdir/build/node_modules/@chargebee/react-native-chargebee/ios/ChargebeeReactNative.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ChargebeeReactNative' from project 'Pods') ▸ (1 failure) ARCHIVE FAILED The following build commands failed: CompileC /Users/expo/Library/Developer/Xcode/DerivedData/Tallio-bbielmlrqyffaodyqcvcjhdlhgly/Build/Intermediates.noindex/ArchiveIntermediates/Tallio/IntermediateBuildFilesPath/Pods.build/Debug-iphoneos/ChargebeeReactNative.build/Objects-normal/arm64/ChargebeeReactNative.o /Users/expo/workingdir/build/node_modules/@chargebee/react-native-chargebee/ios/ChargebeeReactNative.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ChargebeeReactNative' from project 'Pods') (1 failure)

Adding @chargebee/react-native-chargebee to a new project doesn't cause and failed builds, so I am wondering if this has to do with another library that I imported for my project. One of the other libraries I am using (@react-native-firebase/app) uses static frameworks. Here is the implementation instructions from that package:

Open the file ./ios/Podfile and add this line inside your targets (right before the use_react_native line in current react-native releases that calls the react native Podfile function to get the native modules config):

use_frameworks! :linkage => :static To use Static Frameworks on iOS, you also need to manually enable this for the project with the following global to your /ios/Podfile file:

right after use_frameworks! :linkage => :static

$RNFirebaseAsStaticFramework = true

Would static frameworks be causing the compatibility issues? If not, have you ran into this problem in any other scenarios?

FontSanguinetti commented 2 months ago

Same problem here. On android it works just fine but in iOS in throws this same error log: 'ChargebeeReactNative-Swift.h' file not found

cb-haripriyan commented 2 months ago

Hey @kylea3 This could be caused because the library is set as dynamic. can you try by changing it into static? image

kylea3 commented 2 months ago

@cb-haripriyan I have tried setting it to static, but I still get the same error. I've spent the last couple of weeks trying to solve for this issue but haven't found anything. I figured it had to be something with my build settings, but everything seems to be in order.

cb-haripriyan commented 2 months ago

@kylea3 Seems to be an issue when linking the SDK as a static framework rather than a static library.

Brayyan-Yanes commented 1 month ago

Hi!, something like that in your podfile can help you to fix the error as well.


pre_install do |installer|
  $dynamic_frameworks = [
    'ChargebeeReactNative',
  ]
  installer.pod_targets.each do |pod|
    if $dynamic_frameworks.include?(pod.name)
      puts "Overriding the build_type method for #{pod.name}"
      def pod.build_type;
        # NOTE: This syntax only works in cocoapods >= v1.11. Pre 1.11 BuildType was
        # a simple single value.
        BuildType.new(:linkage => :static)
      end
    end
  end
end

target 'YourProject' do ....