react-native-unity-view icon indicating copy to clipboard operation
react-native-unity-view copied to clipboard

React-Native 0.61.2 "React/RCTBridgeModule.h" file not found

Open ziyoshams opened this issue 4 years ago • 24 comments

I could run this library up to version 0.60.5.

But I am getting 'React/RCTBridgeModule.h' file not found with the latest version (0.61.2). A lot of people are suggesting to run pod install for this error, but it does not work.

I know that React.xcodeproj was removed from version 0.61, and it is a part of the issue. Because this package is not updated lately, I am sure we have to find a workaround.

Curious if anyone is getting the same error or already has solved it.

ziyoshams avatar Oct 04 '19 19:10 ziyoshams

same issue!

marlon-wiprud avatar Oct 22 '19 19:10 marlon-wiprud

Have you tried to add library search path for react to UnityView.xcodeproj? In my case it solves the issue.

alisherakb avatar Oct 22 '19 21:10 alisherakb

@alisherakb I tried that, but was not able to get the build working yet - maybe I had an incorrect search path. Mind sharing what search path was working for you?

marlon-wiprud avatar Oct 22 '19 21:10 marlon-wiprud

Try to add the following both to the project and the target Library search paths of RNUnityView.xcodeproj and set it to recursive. ‘$(SRCROOT)/../../../ios/Pods/Headers/Public’

alisherakb avatar Oct 23 '19 06:10 alisherakb

I didn't have time to try the solution given in stackoverflow https://stackoverflow.com/questions/58373425/react-rctdefines-h-file-not-found-rn0-61/58398989#58398989

Wondering if you guys have tried the solution?!

ziyoshams avatar Oct 24 '19 14:10 ziyoshams

Same problem here. Pretty sure it has to do with removal of React.xcodeproj from 0.61 as well.

Tried suggestion here, removing React/ path from the #import statements in react-native-unity-view files, but it doesn't work:

https://github.com/facebook/react-native/issues/25838#issuecomment-547914412

Also tried @alisherakb's suggestion above but didn't solve for me. Also not sure about editing Library search paths; should be Header search paths, no?

Even then, RNUnityView.xcodeproj already has $(SRCROOT)/../../react-native/React set to recursive in header search paths. I'd expect that to work, as the file in question is here:

https://github.com/facebook/react-native/blob/fa4f23e4e8c45b6882a323caebef294ac69cfbf2/React/Base/RCTBridgeModule.h

Wondering if it's a load order issue, since new React is managed by CocoaPods. Perhaps Xcode is trying to build RNUnityView before it builds Pods, and therefore it can't find the file yet (would also explain why it works for some folks, but not others).

benjarwar avatar Nov 08 '19 17:11 benjarwar

Wondering if adding a podspec as per https://github.com/f111fei/react-native-unity-view/issues/136 would help, so that react-native-unity-view is managed by CocoaPods instead of being linked to the parent project manually.

benjarwar avatar Nov 08 '19 19:11 benjarwar

I didn't have time to try the solution given in stackoverflow https://stackoverflow.com/questions/58373425/react-rctdefines-h-file-not-found-rn0-61/58398989#58398989

Wondering if you guys have tried the solution?!

ziyoshams avatar Nov 08 '19 20:11 ziyoshams

Wondering if adding a podspec as per #136 would help, so that react-native-unity-view is managed by CocoaPods instead of being linked to the parent project manually.

I tried creating a podspec - still getting the same error. Not familiar with creating podspec so if anyone has a suggestion here it would be greatly appreciated!


require "json"

package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..","package.json")))
version = package['version']

source = { :git => 'https://github.com/marlon-wiprud/react-native-unity-view.git' }


Pod::Spec.new do |s|
  s.name                   = "RNUnityView"
  s.version                = version
  s.summary                = "A general interface to interact with both incoming and outgoing app links."
  s.homepage               = "https://github.com/marlon-wiprud/react-native-unity-view"
  s.documentation_url      = "https://github.com/marlon-wiprud/react-native-unity-view"
  s.license                = package["license"]
  s.author                 = "f111fei"
  s.platforms              = { :ios => "9.0", :tvos => "9.2" }
  s.source                 = source
  s.source_files           = "*.{m}"
  s.preserve_paths         = "package.json", "LICENSE", "LICENSE-docs"
  s.header_dir             = "RNUnityView"
  s.source_files  = "ios/**/*.{h,m}"

end

marlon-wiprud avatar Nov 08 '19 21:11 marlon-wiprud

@marlon-wiprud did you also add RNUnityView to your project's Podfile and do a cd ios && pod install?

benjarwar avatar Nov 08 '19 21:11 benjarwar

@marlon-wiprud I tried adding .podspec but I get other errors that are in /UnityExport folder. I don't know how to reference them.

But, @alisherakb 's answer actually works.

ziyoshams avatar Nov 08 '19 21:11 ziyoshams

@benjarwar yes - turns out that the error actually came from a different file after I set this up. Making some progress atm , will update if I get this working.

marlon-wiprud avatar Nov 08 '19 21:11 marlon-wiprud

@ziyoshams @marlon-wiprud I'm also trying this out, and now getting this in RNUnityView.h:

'UnityAppController.h' file not found

I suspect we also need to add a Podspec to our local /UnityExport xcode projects, as per "Local Dependencies" section in https://stackoverflow.com/questions/58373425/react-rctdefines-h-file-not-found-rn0-61/58398989#58398989.

benjarwar avatar Nov 08 '19 21:11 benjarwar

Tried adding a Podspec to /UnityExport but it didn't work.

Also tried updating Header Search Paths in both my root project ($(SRCROOT)/UnityExport) and Pods installation of RNUnityView.xcodeproj ($(SRCROOT)/../UnityExport), both set to "recursive". Still getting:

/[redacted]/node_modules/react-native-unity-view/ios/RNUnityView.h:12:9: 'UnityAppController.h' file not found

@marlon-wiprud any luck on your end?

benjarwar avatar Nov 12 '19 15:11 benjarwar

Current thinking is that the header search paths in RNUV itself need to be updated:

https://github.com/f111fei/react-native-unity-view/blob/master/ios/RNUnityView.xcodeproj/project.pbxproj#L251-L253

Those paths are weird. $(SRCROOT) should resolve to the RN project's /ios directory. The current paths are backing out assuming that RNUV is in /node_modules. That may not be the case from the perspective of the built project managed by CocoaPods.

We may also need to update how we're importing, so instead of:

#import "UnityAppController.h"

It should be:

#import <UnityAppController.h>

Because with double quotes, Xcode will look in the current directory of the file making the import first. In our case, the UnityExport files will never be in the same directory as the RNUnityView files.

benjarwar avatar Nov 12 '19 17:11 benjarwar

I decided to go with @alisherakb 's answer. I created this little shell script that runs as part of my npm builds.

  sed -i '.bak' -e 's/react-native\/React/\.\.\/ios\/Pods\/Headers\/Public/g' node_modules/react-native-unity-view/ios/RNUnityView.xcodeproj/project.pbxproj

It updates Header Search in RNUnityView.xcodeproj to $(SRCROOT)/../../../ios/Pods/Headers/Public (@alisherakb 's answer).

ziyoshams avatar Nov 13 '19 00:11 ziyoshams

Has anyone had any success or tip to make this project works on iOS?

rpassareti avatar Nov 13 '19 23:11 rpassareti

@rpassareti we switched back to manually linking RNUnityView.xcodeproj instead of trying to use CocoaPods to manage react-native-unity-view. You can try @ziyoshams shell script above. In our case, we have a fork of of this project, where we updated both the "Header Search Paths" and "Library Search Paths" to include $(SRCROOT)/../../../ios/Pods/Headers/Public set to recursive like so:

Screen Shot 2019-11-14 at 9 50 24 AM

That got us past the initial build errors described in this issue, but we're encountering others and haven't yet successfully built with iOS and RN 0.61.

benjarwar avatar Nov 14 '19 14:11 benjarwar

@benjarwar To be clear, my script actually replaces /react-native/React header search path, because we dont need it.
It replaces:
$(SRCROOT)/../../react-native/React to
$(SRCROOT)/../../../ios/Pods/Headers/Public

ziyoshams avatar Nov 14 '19 15:11 ziyoshams

@ziyoshams gotcha. But if we were to PR this change to the Xcode project, I think we'd want to leave in the old search paths for backwards compatibility.

benjarwar avatar Nov 14 '19 15:11 benjarwar

@ziyoshams gotcha. But if we were to PR this change to the Xcode project, I think we'd want to leave in the old search paths for backwards compatibility.

Yes. That's why I run that script in my npm build scripts. (e.g postinstall)

ziyoshams avatar Nov 14 '19 15:11 ziyoshams

For anyone interested in getting this lib working with Pods, we figured out a solution. See comments in https://github.com/f111fei/react-native-unity-view/issues/136.

benjarwar avatar Nov 19 '19 19:11 benjarwar

Hi @benjarwar Did you get success build with manual linking?

sburaksak avatar Feb 12 '20 13:02 sburaksak

@sburaksak we did, with @ziyoshams's script. But then later opted to switch to CocoaPods as discussed in https://github.com/f111fei/react-native-unity-view/issues/136.

benjarwar avatar Feb 12 '20 23:02 benjarwar