react-native-notification-banner icon indicating copy to clipboard operation
react-native-notification-banner copied to clipboard

Header not found error

Open nickpalmer opened this issue 5 years ago • 20 comments

I am running:

[email protected]
[email protected]

In my Podfile I have added the following, per the instructions:

  pod 'BRYXBanner', :git => 'https://github.com/prscX/BRYXBanner.git', :branch => 'master'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name.include?('BRYXBanner')
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '4.2'
        end
      end
    end
  end

When I run react-native run-ios I am getting this error:

RNNotificationBanner.h:3:9: fatal error: 'BRYXBanner/BRYXBanner-Swift.h' file not found
#import "BRYXBanner/BRYXBanner-Swift.h"

If I add use_frameworks! to the Podfile the error goes away. If I change to use_modular_headers! the error also goes away. Both of these settings impact other modules though, and in particular Firebase/Core has a problem when they are on.

Any workaround?

nickpalmer avatar Oct 08 '19 06:10 nickpalmer

@nickpalmer I found a workaround where I have the same as you in the Podfile (without use_frameworks or use_modular_headers).

Then I followed those instructions (found in another repo):

  1. Open the Xcode workspace located inside the ios folder of your app, and add an empty Swift file if you don't have at least one:

    • Select File/New/File...
    • Choose Swift file and click Next.
    • Name it however you want, select your application target and create it.
    • Accept to create Objective-C bridging header.
  2. Enter ios folder and run pod update

I hope this can help until there's a better answer.

ghitier avatar Oct 14 '19 11:10 ghitier

@nickpalmer I found a workaround where I have the same as you in the Podfile (without use_frameworks or use_modular_headers).

Then I followed those instructions (found in another repo):

  1. Open Xcode workspace located inside ios folder and add empty Swift file if you don't have at least one:

    • Select File/New/File...
    • Choose Swift file and click Next.
    • Name it however you want, select your application target and create it.
    • Accept to create Objective-C bridging header.
  2. Enter ios folder and run pod update

I hope this can help until there's a better answer.

Inside my app or notification-banner?

SmirnovM91 avatar Dec 05 '19 11:12 SmirnovM91

Inside my app or notification-banner?

@SmirnovM91 inside your app

ghitier avatar Dec 05 '19 11:12 ghitier

Inside my app or notification-banner?

@SmirnovM91 inside your app

I did it, but it is not working (banner.swift)

image

SmirnovM91 avatar Dec 05 '19 11:12 SmirnovM91

I did it, but it is not working (banner.swift)

@SmirnovM91 You do have the bridging header apparently, so thats fine.

Here's what I have at the end of my Podfile if it may help:

target 'FreshmileApp' do
  ...
  use_native_modules!

  pod 'BRYXBanner', :git => 'https://github.com/prscX/BRYXBanner.git', :branch => 'master'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name.include?('BRYXBanner')
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '4.2'
        end
      end
    end
  end
end

Also make sure to run pod update

Other than that I found out out about the bridging header trick from the install instructions of react-native-ble-plx, you might want to take a look a this repo as well. Unfortunately this method did the trick for me and I don't know any other way to make this work.

ghitier avatar Dec 05 '19 12:12 ghitier

I have the same pod file as you, but it is not working, the problem still exists

RNNotificationBanner.h:3:9: fatal error: 'BRYXBanner/BRYXBanner-Swift.h' file not found

SmirnovM91 avatar Dec 05 '19 12:12 SmirnovM91

I have the same pod file as you, but it is not working, the problem still exists

RNNotificationBanner.h:3:9: fatal error: 'BRYXBanner/BRYXBanner-Swift.h' file not found

@SmirnovM91 Awww, you're right I forgot about that import. I changed it:

-#import "BRYXBanner/BRYXBanner-Swift.h"
+@import BRYXBanner;

ghitier avatar Dec 05 '19 12:12 ghitier

I have the same pod file as you, but it is not working, the problem still exists RNNotificationBanner.h:3:9: fatal error: 'BRYXBanner/BRYXBanner-Swift.h' file not found

@SmirnovM91 Awww, you're right I forgot about that import. I changed it:

-#import "BRYXBanner/BRYXBanner-Swift.h"
+@import BRYXBanner;

Thanks a lot, it is working now!

SmirnovM91 avatar Dec 05 '19 12:12 SmirnovM91

Same error with latest version.

.../node_modules/react-native-notification-banner/ios/RNNotificationBanner.h:3:9: 'BRYXBanner/BRYXBanner-Swift.h' file not found

sarmadmakhdoom avatar Jan 17 '20 15:01 sarmadmakhdoom

Same error with latest version.

.../node_modules/react-native-notification-banner/ios/RNNotificationBanner.h:3:9: 'BRYXBanner/BRYXBanner-Swift.h' file not found

try to use @ghitier's solution, for me it is working

SmirnovM91 avatar Jan 17 '20 15:01 SmirnovM91

Same error with latest version. .../node_modules/react-native-notification-banner/ios/RNNotificationBanner.h:3:9: 'BRYXBanner/BRYXBanner-Swift.h' file not found

try to use @ghitier's solution, for me it is working

That does not work either. It started to produce more errors around Banner.

sarmadmakhdoom avatar Jan 17 '20 17:01 sarmadmakhdoom

I think the Banner version currently installed does have show or dismiss methods exposed to ObjectiveC. What BRYXBanner version should it install to go with the library?

PS: Android seems to be working fine.

sarmadmakhdoom avatar Jan 17 '20 17:01 sarmadmakhdoom

You need to configure Podfile similar to below one:

use_native_modules!

pod 'RNNotificationBanner', :path => '../node_modules/react-native-notification-banner/ios'

use_frameworks!

pod 'BRYXBanner', :git => 'https://github.com/prscX/BRYXBanner.git', :branch => 'master'

post_install do |installer|
 installer.pods_project.targets.each do |target|
   if target.name.include?('BRYXBanner')
     target.build_configurations.each do |config|
       config.build_settings['SWIFT_VERSION'] = '4.2'
     end
   end
 end
end

This works in example and other project where I am using. Let me know incase does not work.

Thanks </ Pranav >

prscX avatar Jan 23 '20 08:01 prscX

The whole problem of this issue is that using "use_frameworks!" breaks about every second react-native module out there, so it would be nice if there was a way to make it work without.

@SmirnovM91 Awww, you're right I forgot about that import. I changed it:

-#import "BRYXBanner/BRYXBanner-Swift.h"
+@import BRYXBanner;

That solution works, but it's more of a hack, maybe it's possible to merge such or similar change to the package?

IMalyugin avatar Feb 06 '20 08:02 IMalyugin

@prscX could you please make a release with this import changed?

VasiliSolodar avatar Apr 21 '20 12:04 VasiliSolodar

also have this issue using latest versions.

jonasgroendahl avatar May 07 '20 16:05 jonasgroendahl

@prscX please make a release with the import fix. If I did it manually, it works

batrinuvlad avatar May 07 '20 20:05 batrinuvlad

Hi, Any update on this? Facing same problem here and I can not do manually modification to the modules.

ethyaan avatar May 16 '20 05:05 ethyaan

@ehsanagh Take a look at this https://www.npmjs.com/package/patch-package With patch-package you can manually modify a module and add a post install script to automatically apply it after each install. This way it will work even for ci/cd or after package version bump.

It's a good approach as I've been forced to patch up around 40% of the react native npm packages out there within a month of working with RN. Gotta start hacking stuff sooner or later :)

IMalyugin avatar May 16 '20 16:05 IMalyugin

The whole problem of this issue is that using "use_frameworks!" breaks about every second react-native module out there, so it would be nice if there was a way to make it work without.

@SmirnovM91 Awww, you're right I forgot about that import. I changed it:

-#import "BRYXBanner/BRYXBanner-Swift.h"
+@import BRYXBanner;

That solution works, but it's more of a hack, maybe it's possible to merge such or similar change to the package?

Followed this workaround, but I am now running into this error.

module map file '/Users/me/Library/Developer/Xcode/DerivedData/App-amiwxgwwlncvtifvktjjajkbilap/Build/Products/Debug-iphonesimulator/BRYXBanner/BRYXBanner.modulemap' not found

KarthikKnot1 avatar Apr 15 '21 18:04 KarthikKnot1