Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.49k stars 589 forks source link

WatermelonDB/DatabaseBridge.swift:7:23: error: cannot find type 'RCTBridge' in scope #1558

Open muslimmuda15 opened 1 year ago

muslimmuda15 commented 1 year ago

After 2 years I'm back again to my react-native init project. I have update all my dependency and update my XCode in latest. I'm follow the latest installation instruction. but I get this error. error: cannot find type 'RCTBridge' in scope

env:

XCode 14.2
"@nozbe/watermelondb": "^0.25.5",
"react": "18.2.0",
"react-native": "0.71.4",

PodFile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, min_ios_version_supported
prepare_react_native_project!

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

def pod_defined
  config = use_native_modules!
  flags = get_default_flags()

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'FirebaseSessions', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true

  pod 'WatermelonDB', :path => '../node_modules/@nozbe/watermelondb'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true
  pod 'simdjson', path: '../node_modules/@nozbe/simdjson'

  pod 'FirebaseAnalytics'
  pod 'FirebaseAuth'
  pod 'FirebaseFirestore'

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
end

target 'Proj' do
  pod_defined
end

target 'ProjUAT' do
  pod_defined
end

target 'ProjLocal' do
  pod_defined
end

target 'Proj-tvOS' do
  pod_defined

  target 'Proj-tvOSTests' do
    inherit! :complete
  end
end

post_install do |installer|
    find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
    "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
    find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
    "RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")

    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

I set the header like this

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTViewManager.h>
#import <React/RCTBridgeModule.h>

// Silence warning
#import "../node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/SupportingFiles/Bridging.h"

And I place this image

Here the error detailed when I'm running react-native run-ios --simulator='iPhone 11' --configuration='Debug' --scheme='ProjUAT'

/Users/laptop/Documents/PROJECT/proj/react-native/node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/DatabaseBridge.swift:7:23: error: cannot find type 'RCTBridge' in scope
    @objc var bridge: RCTBridge?
                      ^~~~~~~~~

What are missing?

leomeneguzzi commented 1 year ago

Same here :(

vinesh4Real commented 7 months ago

@leomeneguzzi @muslimmuda15 hi guys. Any update on how or if you solved it?

muslimmuda15 commented 6 months ago

The temporary solve, I just create new project, then reconfiguration your watermelondb just like documentation, copy all files from old project, to new project. done