OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.57k stars 374 forks source link

[Bug]: OneSignalExtension No such module #1728

Open phuvinhng opened 2 months ago

phuvinhng commented 2 months ago

What happened?

In project react native, I have installed OneSignalExtension. However, OneSignalExtension not found in file NotificationService

Steps to reproduce?

1. rm -rf Pods
2. rm -rf Podfile.lock
3. Clean project
4. rm -rf build folder ios

What did you expect to happen?

I expect app running

React Native OneSignal SDK version

5.2.2

Which platform(s) are affected?

Relevant log output

No response

Code of Conduct

phuvinhng commented 2 months ago
Screenshot 2024-08-09 at 08 56 28
phithu commented 2 months ago

+1

feliper-botelho commented 2 months ago

+1

anasvemmully commented 2 months ago

+1

nan-li commented 2 months ago

Hi, can you share what you have in your Podfile?

matheusleite commented 2 months ago

+1

ChoiHyeongu commented 1 month ago

+1

andrzli commented 1 month ago

+1

davide-granello commented 3 weeks ago

+1

Rohit-vinfotech commented 2 weeks ago

HELLO ALL

I have resolved this by updating pod file please update your Main target name

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

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

production = ENV["PRODUCTION"] == "1"

target 'your_main_target' do
  config = use_native_modules!
  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true
  # Flags change depending on the env values.
  flags = get_default_flags()

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

  setup_permissions([
    'Camera',
    'LocationWhenInUse',
    'MediaLibrary',
    'Notifications',
    'PhotoLibrary',
    'PhotoLibraryAddOnly',
  ])
end

# OneSignal Notification Service Extension target
target 'OneSignalNotificationServiceExtension' do
  use_frameworks! :linkage => :static
  pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0'
end

# Combined post_install hook for both targets
post_install do |installer|
  # For DigilegalPro and general post install tasks
  react_native_post_install(installer)
  __apply_Xcode_12_5_M1_post_install_workaround(installer)

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
      config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"

      # This setting is required for app extensions
      if target.name == 'OneSignalNotificationServiceExtension'
        config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'YES'
      end
    end
  end

  # Xcode 14 resource bundle signing fix
  installer.target_installation_results.pod_target_installation_results
  .each do |pod_name, target_installation_result|
    target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
      resource_bundle_target.build_configurations.each do |config|
        config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
      end
    end
  end
end