Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ziyoshams opened this issue Oct 4, 2019 · 24 comments
Open

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

ziyoshams opened this issue Oct 4, 2019 · 24 comments

Comments

@ziyoshams
Copy link

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 ziyoshams changed the title React-Native 0.61.2 '"React/RCTBridgeModule.h" file not found' React-Native 0.61.2 "React/RCTBridgeModule.h" file not found Oct 4, 2019
@marlon-wiprud
Copy link

same issue!

@alisherakb
Copy link

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

@marlon-wiprud
Copy link

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

@alisherakb
Copy link

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’

@ziyoshams
Copy link
Author

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

@benjarwar
Copy link

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

@benjarwar
Copy link

benjarwar commented Nov 8, 2019

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.

@ziyoshams
Copy link
Author

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

@marlon-wiprud
Copy link

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

@benjarwar
Copy link

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

@ziyoshams
Copy link
Author

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

@marlon-wiprud
Copy link

marlon-wiprud commented Nov 8, 2019

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

@benjarwar
Copy link

benjarwar commented Nov 8, 2019

@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
Copy link

benjarwar commented Nov 12, 2019

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
Copy link

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.

@ziyoshams
Copy link
Author

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

@rpassareti
Copy link

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

@benjarwar
Copy link

benjarwar commented Nov 14, 2019

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

@ziyoshams
Copy link
Author

@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

@benjarwar
Copy link

@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
Copy link
Author

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

@benjarwar
Copy link

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

@sburaksak
Copy link

sburaksak commented Feb 12, 2020

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

@benjarwar
Copy link

benjarwar commented Feb 12, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants