Skip to content

[🐛] 🔥 Cannot find "Messaging" in scope [iOS] firebase messaging #8357

Open
@cw-nikhilnaik

Description

@cw-nikhilnaik

Issue

After the conversion from obj-c to swift, I am no longer be able to create build using Messaging as it is unable to find it in scope


Project Files

Javascript

Click To Expand

package.json:

  "dependencies": {
    "@ptomasroos/react-native-multi-slider": "2.2.2",
    "@react-native-async-storage/async-storage": "1.19.3",
    "@react-native-community/netinfo": "11.3.1",
    "@react-native-firebase/analytics": "21.9.0",
    "@react-native-firebase/app": "21.9.0",
    "@react-native-firebase/auth": "21.9.0",
    "@react-native-firebase/crashlytics": "21.9.0",
    "@react-native-firebase/installations": "21.9.0",
    "@react-native-firebase/perf": "21.9.0",
    "@react-native-firebase/remote-config": "21.9.0",
    "@react-native/normalize-color": "2.1.0",
    "@react-navigation/drawer": "7.1.1",
    "@react-navigation/material-top-tabs": "7.1.0",
    "@react-navigation/native": "7.0.14",
    "@react-navigation/native-stack": "7.2.0",
    "@react-navigation/stack": "7.1.1",
    "@shopify/flash-list": "1.6.3",
    "hoist-non-react-statics": "3.3.2",
    "jsc-android": "250231.0.0",
    "lodash": "4.17.21",
    "moment": "2.29.4",
    "prop-types": "15.7.2",
    "react": "18.3.1",
    "react-native": "0.77.1",
    "react-native-autocomplete-input": "5.4.0",
    "react-native-autoheight-webview": "1.6.5",
    "react-native-blob-util": "0.19.1",
    "react-native-check-box": "2.1.7",
    "react-native-code-push": "8.1.1",
    "react-native-easy-grid": "0.2.2",
    "react-native-element-dropdown": "2.10.1",
    "react-native-fast-image": "8.6.3",
    "react-native-geolocation-service": "5.3.1",
    "react-native-gesture-handler": "2.23.1",
    "react-native-google-maps-directions": "2.1.1",
    "react-native-google-mobile-ads": "14.9.0",
    "react-native-image-picker": "8.1.0",
    "react-native-linear-gradient": "2.8.3",
    "react-native-material-buttons": "0.6.0",
    "react-native-material-dropdown": "0.11.1",
    "react-native-material-ripple": "0.9.1",
    "react-native-modal": "13.0.1",
    "react-native-orientation-locker": "1.5.0",
    "react-native-pager-view": "6.7.0",
    "react-native-permissions": "5.2.5",
    "react-native-progress-circle": "2.1.0",
    "react-native-raw-bottom-sheet": "2.2.0",
    "react-native-reanimated": "3.16.7",
    "react-native-render-html": "6.3.4",
    "react-native-safe-area-context": "5.1.0",
    "react-native-screens": "4.5.0",
    "react-native-share": "12.0.9",
    "react-native-svg": "15.11.1",
    "react-native-swiper": "1.6.0",
    "react-native-tab-view": "3.5.2",
    "react-native-thumbnail-video": "0.1.2",
    "react-native-viewpager-carousel": "0.3.2",
    "react-native-webview": "13.13.0",
    "react-native-youtube-iframe": "2.3.0",
    "react-navigation": "4.4.4",
    "react-redux": "8.1.2",
    "realm": "12.14.1",
    "react-native-network-logger": "1.15.0",
    "recyclerlistview": "4.2.0",
    "redux": "4.2.1",
    "redux-logger": "3.0.6",
    "redux-persist": "6.0.0",
    "redux-thunk": "2.4.2"
  },
  "devDependencies": {
    "@babel/core": "7.25.2",
    "@babel/preset-env": "7.25.3",
    "@babel/runtime": "7.25.0",
    "@react-native-community/cli": "15.0.1",
    "@react-native-community/cli-platform-android": "15.0.1",
    "@react-native-community/cli-platform-ios": "15.0.1",
    "@react-native/babel-preset": "0.77.1",
    "@react-native/eslint-config": "0.77.1",
    "@react-native/metro-config": "0.77.1",
    "@react-native/typescript-config": "0.77.1",
    "@types/jest": "29.5.13",
    "@types/react": "18.2.6",
    "@jest/create-cache-key-function": "26.5.0",
    "@testing-library/react-native": "^9.0.0",
    "@types/react-native": "0.71.3",
    "@types/react-test-renderer": "^18.0.0",
    "babel-eslint": "8.2.3",
    "babel-plugin-module-resolver": "3.1.3",
    "babel-plugin-transform-remove-console": "6.9.4",
    "eslint": "8.19.0",
    "jest": "29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.3.1",
    "typescript": "5.0.4",
    "jetifier": "1.6.4",
    "pretty-quick": "^3.1.0",
    "react-dom": "18.2.0",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.15.6",
    "enzyme-react-16-adapter-setup": "0.1.0",
    "enzyme-to-json": "3.6.2",
    "redux-mock-store": "^1.5.3",
    "husky": "9.0.11",
    "lint-staged": "15.2.7"
  },

iOS

Click To Expand

ios/Podfile:

def node_require(script)
  # Resolve script with node to allow for hoisting
  require Pod::Executable.execute_command('node', ['-p',
    "require.resolve(
      '#{script}',
      {paths: [process.argv[1]]},
    )", __dir__]).strip
end

# Use it to require both react-native's and this package's scripts:
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')

setup_permissions([
  'AppTrackingTransparency',
  'LocationAlways',
  'LocationWhenInUse',
  'Reminders',
  'StoreKit',
])

platform :ios, min_ios_version_supported
prepare_react_native_project!

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

target 'BWReactApp' do
  config = use_native_modules!
  use_modular_headers!

  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true

  # FCM(Firebase push notification) setup scripts start --->
  pod 'Firebase'
  pod 'FirebaseCoreInternal'
  pod 'GoogleUtilities'
  pod 'FirebaseCore'
  pod 'GoogleDataTransport'
  pod 'FirebaseCoreExtension'
  pod 'FirebaseInstallations'
  pod 'nanopb'
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Analytics'
  # <--- FCM(Firebase push notification) setup scripts End 

  use_react_native!(
    :path => config[:reactNativePath],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )
  end
end

AppDelegate.swift:

import UIKit
import React
import Firebase
import CodePush
import React_RCTAppDelegate
import ReactAppDependencyProvider

@main
class AppDelegate: RCTAppDelegate {

    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        FirebaseApp.configure()
        Messaging.messaging().delegate = self
        self.moduleName = "BWReactApp"
        self.dependencyProvider = RCTAppDependencyProvider()
        self.initialProps = [:]
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    
    override func sourceURL(for bridge: RCTBridge) -> URL? {
    self.bundleURL()
  }
 
  override func bundleURL() -> URL? {
#if DEBUG
    RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
    Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
  }
    
}


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

System:
  OS: macOS 15.1.1
  CPU: (8) arm64 Apple M2
  Memory: 111.17 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.3
    path: ~/.nvm/versions/node/v18.20.3/bin/node
  Yarn: Not Found
  npm:
    version: 10.7.0
    path: ~/.nvm/versions/node/v18.20.3/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.2 AI-222.4459.24.2221.10121639
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.21
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.1
    wanted: 0.77.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 21.9.0
  • Firebase module(s) you're using that has the issue:
    • messaging
  • Are you using TypeScript?
    • Y & 5.0.4


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions