f111fei/react-native-unity-view

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

ziyoshams opened this issue · 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.

same issue!

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

@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?

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’

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?!

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:

facebook/react-native#25838 (comment)

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).

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 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?!

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 did you also add RNUnityView to your project's Podfile and do a cd ios && pod install?

@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.

@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.

@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.

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?

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.

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).

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

@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 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 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.

@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)

For anyone interested in getting this lib working with Pods, we figured out a solution. See comments in #136.

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

@sburaksak we did, with @ziyoshams's script. But then later opted to switch to CocoaPods as discussed in #136.