react-native-share-extension: Error compiling with React Native 0.61.0 with Xcode: "'React/RCTBridgeModule.h' file not found"
My project stopped building as soon as I updated to the latest React Native version: 0.61.0. Had it working perfectly in 0.60.5 and lower.
Examining the error I notice this is probably related to the absence of node_modules/react-native/React.xcodeproj since 0.61.0. As adding that file to the Libraries folder in Xcode ánd using it as a Depedency under Build Phases did the trick in resolving the “‘React/RCTBridgeModule.h’ file not found” error in 0.60.5 and below. Also mentioned here.
Does anybody have an idea to get this to work again without React.xcodeproj?
I already tried updating the header search paths. But that does not work:
$(inherited)
$(SRCROOT)/../node_modules/react-native-share-extension/ios
$(SRCROOT)/../node_modules/react-native/React
Error details:
/node_modules/react-native-share-extension/ios/ReactNativeShareExtension.h:2:9: ‘React/RCTBridgeModule.h’ file not found
react-native-share-extension/ios/ReactNativeShareExtension.h
#import <UIKit/UIKit.h>
#import <React/RCTBridgeModule.h>
@interface ReactNativeShareExtension : UIViewController<RCTBridgeModule>
- (UIView*) shareView;
@end
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 41
Commits related to this issue
- feat: Adding ReactNativeShareExtension.podspec per https://github.com/alinz/react-native-share-extension/issues/182 — committed to Meandmybadself/react-native-share-extension by Meandmybadself 5 years ago
- Create ReactNativeShareExtension.podspec https://github.com/alinz/react-native-share-extension/issues/182#issuecomment-534993812 — committed to InsigniaVenturesPartners/react-native-share-extension by phuoc-insignia 5 years ago
- Add `podspec` file Why: * RN > 0.60 requires to link libs automatically, so we need to add a `podspec` file to reference it in projects `Podfile`. Based on: https://github.com/alinz/react-native-shar... — committed to verypossible/react-native-share-extension by deleted user 4 years ago
- :construction_worker: moving podspec to root to make autolinking in rn >= 0.60 possible — committed to rastapasta/react-native-file-share-intent by rastapasta 5 years ago
Fixed it by adding a
.podspecfile in the root and treat the package as a pod dependency now.The steps below are probably only for react native 0.61.0 and higher. Not tested with a lower version.
Please do not use my forked package mentioned below in your project, as I do not give support for that. I’ve forked this share extension project to fit my needs only. And to provide an example for others.
Follow the installation steps here. You can skip the parts about adding files to the Libraries folder and the Linked Libraries and Frameworks. Because you do not need that in React Native 0.61 and higher. Please follow the other steps exactly like mentioned. It’s really important to double check this before following the steps below.
Fork this project. Because that (this) share extension project is clearly abandoned. You’re now going to manage this on your own as this allows you to add a
podspecfile.Create a
ReactNativeShareExtension.podspecfile in the root of your newly forked share extension package. Example from my fork of this project.Change the
s.sourceurl in the.podspecfile to match your forked repo url, ending with.git. Something like this:Push those changes to your forked repository
masterbranch. If you do any other changes in your share extension repo you need to reinstall the share extension throughnpm install,pod deingegrateandpod install, so it fetches the changes from the repo. Just something you need to keep in mind.Edit your
./package.jsonin your own react native project and use your forked project as the dependency forreact-native-share-extension. ChangeYOUR_USERNAMEto your Github username:Run
npm installin the root of your React Native project, this will install the share extension files from your own github repo, including the new.podspecfile.Go to the
./iosdirectory and add this to yourPodfile, just below the React pods:0.61.x:Run
pod installin the./iosdirectoryOpen Xcode using your projects
.xcworkspacefile, NOT the.xcodeprojfile at./ios/YourApp.xcworkspaceWhen opened in Xcode, go to:
File>Workspace Settings> Make sureBuild SystemisLegacy Build System.Make sure
React.xcodeprojectandReactNativeShareExtension.xcodeprojare not in yourLibrariesdirectory. If they are, selectDeleteand remove their reference (not trash it).Remove all other references which you don’t need any more from
Frameworks and LibrariesunderGeneralon your main and share extension target. Examples how my personalFrameworks and Librarieslook like:Example my main target:
Example my extension target:
Remove
React (React)fromBuild Phases>Depedencieson your main target and share extension target, if present.Go to
Product>Scheme>Manage schemes> Select your share extension schema and thenEdit. Go toBuildon the top-left.Remove the “old”
Reactfrom your extension’s schema, if present.Make sure
Parallize Buildis unchecked on your main schema and share extension schema.On the Share Extension schema screen add
ReactfromPods/Reactas a new target using the small+Close that schemes screen
Make sure the
Header Search PathsinBuild Settingsin your main app target ánd share extension target has$(inherited)on top withnon-recursiveselected. Delete any other reference except the ones your app really needs. Also make sure thereact-native-share-extensionis not present there anymore. If it is, remove it. You’ll probably only need$(inherited) non-recursivein there.In xcode press and hold
option+shift+CMD+kto clean the build folderBuild. Should now succeed using react-native 0.61.0
Try add $(inherited) to top of Build Settings -> Other Linker Flags
i ve used this package with all new features with react native greater than 0.60 support react-native-receive-sharing-intent
On 0.61.0 and following @jvandenaardweg’s instructions in the second post gets me to a point with the following error output on build of my share ext (note that
MemexShareis the name of my share ext’s main class):Has anyone experienced this? If not, does anyone know what could cause such an error?
I’ve been stuck at this stage, messing around with different settings that I don’t fully understand for hours now. I feel like I’ve read through and followed the main repo instructions + @jvandenaardweg’s enough times now that I’m fairly confident I’m not missing any steps, although I always get back to this point.
When I use the solution, I get another pack of errors about Mach-O Linker.
Could anyone help me?
I recently helped another developer with the setup of this which had the same problem. I notice the following was missing in his setup:
Targets -> “ShareExtension” -> Build Phases -> Run Script:
Add it by: Select your “ShareExtension” target -> In the top menu: Editor -> Add Build Phase -> Add Run Script Build Phase.
Which is actually part of the original readme.
Might be unrelated, but I also noticed I had this in my
Info.plistin the share extension folder, which he was missing:I managed to fix the error by adding
$(inherited)to the extension targetHeader Search PathsandLibrary Search Paths.then adding :
just before
use_native_modules!in the Podfile and doingpod installYeah, its not there in the list, and turns out i didnt need it, i managed to solve my issue, after checking around in the logs i found out that firebase was the cause of this issue, it was crashing the extension because it wasn’t initialized. after a few tries i have it working now. Thanks for all the help guys !
Got it working on 0.63.2 by following above comment, but without the need to update the
Podfilewith this line:pod 'ReactNativeShareExtension', :podspec => '../node_modules/react-native-share-extension/ReactNativeShareExtension.podspec'Thanks @jvandenaardweg
We needed one additional step to get this working with rn 0.60.6 which was to remove
-ObjCand-lc++from Build Settings > Linking > Other Linker Flags and replace with$(inherited). Leaving the existing flags was resulting in duplicate symbol errors.Ultimately the steps we took to get this working with 0.60.6 were:
Update podfile as mentioned in @jvandenaardweg’s earlier comment
pod updateNotice that a
libPods-YourApp-YourShareExtension.alink was created in General > Frameworks and Libraries. We were able to get the ShareExtension to build at this phase but were running into the error mentioned in #48. This was prior to removing the manually linked libraries that were present before the upgrade. Remove all links other thanJavaScriptCore.frameworkand the libPods link.Next we were seeing duplicate symbol errors causing the build to fail which was resolved by updating the Other Linker Flags as mentioned earlier.
Thanks for all your work on this @jvandenaardweg
Thanks @jvandenaardweg
"react-native": "0.60.5"worked!If you are familiar with how react native works, then you know that
libReactNativeConfigserves just as an example to show there could be other options there if your project requires it 🙂So it’s not required if your project doesn’t have it.
I’ll remove it from the steps to prevent confusion.
Please create an other issue for 0.60.x and lower. So we can keep this for 0.61.x, as there are differences between those versions on how to get this to work
I am using 0.60.4 and I having the compiling error : React/RCTBridgeModule.h file not found I am around two days trying to figure out what I am doing wrong.
Thank you very much in advanced.
I got it working on both iOS and Android for RN 0.61.2 following these latest instructions. Thanks!
I NEED HELP!!! Please write detailed instructions on how to run this all on a clean project. I try to install according to the instructions and still get an error:
Xcode 10.3 "react": "16.9.0", "react-native": "0.61.1",