I'm trying to create a native (iOS) module for a React Native app using Swift. I want to expose a method on the module that returns a promise, using functions of type RCTPromiseResolveBlock
and RCTPromiseRejectBlock
, both of which are declared in React Native's RCTBridgeModule.h
header. However, my build fails with the message "Use of undeclared type..." for both of these types.
I had already created a bridging header (automatically using Xcode) for another purpose, so I believe importing React/RCTBridgeModule.h
is all that I'd need to supply the types mentioned above. Presumably I've misconfigured something, as this doesn't fix the issue. I've tried setting up a fresh project and everything works as expected there, but I can't seem to find a difference that would cause my project's build to fail.
Some relevant configuration details:
- Bridging header named
<ProjectName>-Bridging-Header.h
and stored in my source directory. I moved it around to confirm that Xcode is finding it (the build fails differently when it's not in the right place). - The contents of the bridging header is simply:
#import <React/RCTBridgeModule.h>
- In my project build settings:
<ProjectName>-Bridging-Header.h
is configured as the "Objective-C Bridging Header"- "Install Objective-C Compatibility Header" is set to "Yes"
- "Precompile Bridging Header" is set to "Yes"
- When I type alias the missing types the project builds and runs as expected
- I have some third-party Swift libraries installed (one using
react-native link
and one using a Git submodule) - I've tried cleaning the build folder, reinstalling
node_modules
and deleting Xcode derived data, all to no effect.
Is my project misconfigured or have I otherwise missed something important?