swiftreact-nativereact-native-turbomodulenew-architecture

Cannot find interface declaration for 'RCTDefaultReactNativeFactoryDelegate', superclass of 'ReactNativeDelegate'


Using Swift in Your iOS Native Modules: https://reactnative.dev/docs/next/the-new-architecture/turbo-modules-with-swift

When following this tutorial to write TurboModules in Swift, the following compilation error occurs:

DerivedSources/AppName-Swift.h:330:34 Cannot find interface declaration for 'RCTDefaultReactNativeFactoryDelegate', superclass of 'ReactNativeDelegate'

(Note: 'AppName' is your app’s name.)


Solution

  • To insert #import "RCTDefaultReactNativeFactoryDelegate.h" before #import "AppName-Swift.h", you can modify your Objective-C file like this:

    enter image description here