Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbol: _OBJC_CLASS_$_RCTInspectorDevServerHelper #1359

Closed
allemanfredi opened this issue Feb 3, 2022 · 13 comments
Closed

Undefined symbol: _OBJC_CLASS_$_RCTInspectorDevServerHelper #1359

allemanfredi opened this issue Feb 3, 2022 · 13 comments
Assignees

Comments

@allemanfredi
Copy link

allemanfredi commented Feb 3, 2022

Description:

Hello everyone, After having followed your documentation and after having set config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO' within the Podfile, i started to receive the following errors during the build.

Undefined symbol: vtable for facebook::react::HermesExecutorFactory
Undefined symbol: _OBJC_CLASS_$_RCTInspectorDevServerHelper

If i don't set config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO', i receive this error:

 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

Environment

  • react-native-onesignal: 4.3.2
  • react-native: 0.66.3
@mdeliadi
Copy link

mdeliadi commented Feb 3, 2022

Hi everyone!

I have the same issue since this morning; the awful part of my story is that my codebase built without errors until yesterday evening, but today not anymore.

I've tried to use a notification service extension written in both Objective-C and Swift, re-installed cocoapods, removed its cache, changed its version, re-installed the pods an enormous amount of times, set APPLICATION_EXTENSION_API_ONLY to NO first for all the pods, and then for React-Core and RNPermissions pods only, added missing dependencies when able but in the end I'm still stuck with the same errors above.

Please help, I would like to have this working and I'm tired of reading "please reinstall your pods, you will be fine" :(

@jkasten2
Copy link
Member

@mdeliadi @allemanfredi Thanks for the details! Looking to narrow down this issue, to specific react-native versions and settings.

@mdeliadi You noted you did not have the issue originally with OneSignal, but then broke the next day. Did you upgrade your version of react-native or anything else?

@mdeliadi @allemanfredi Could you share your Podfile as well?

This issue looks like it could be related #1360.

@mdeliadi
Copy link

Hi @jkasten2 !

React Native version should be 0.66.3, the next day I've not updated anything, I've just removed my Pods and node_modules folders, Podfile.lock, package-lock.json, run npm i and after pod install!

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, '11.0'

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
          system("chmod +w " + name)
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

def react_native_post_install(installer)
  installer.pods_project.targets.each do |target|
		target.build_configurations.each do |config|
		  # Set 9.0 as min version for all
		  if Gem::Version.new('11.0') > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
			  config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
		  end
		end
	end
end

permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
pod 'MultiplatformBleAdapter', :git => 'https://github.com/below/MultiPlatformBleAdapter', :tag => '0.1.9'

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => true
  )



  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  use_flipper!({ 'Flipper-Folly' => '2.6.7', 'Flipper-RSocket' => '1.4.3' , 'Flipper' => '0.88.0' })

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end

Thanks for your help! Any suggestion will be very appreciated!

@mdeliadi
Copy link

Hi @jkasten2 ! Any news, please? I'm still blocked on this issue! Thanks.

@jkasten2
Copy link
Member

jkasten2 commented Mar 1, 2022

@mdeliadi @allemanfredi Can you try moving OneSignalNotificationServiceExtension inside your main target?
Example:
Change this:

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => true
  )



  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  use_flipper!({ 'Flipper-Folly' => '2.6.7', 'Flipper-RSocket' => '1.4.3' , 'Flipper' => '0.88.0' })

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end

To this:

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => true
  )



  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  use_flipper!({ 'Flipper-Folly' => '2.6.7', 'Flipper-RSocket' => '1.4.3' , 'Flipper' => '0.88.0' })

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

  target 'OneSignalNotificationServiceExtension' do
    pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
  end
end

This worked for another developer (noted in #1360 (comment)) but not sure exactly why it is required in this scenario when hermes_enabled is set to true.

@mdeliadi
Copy link

mdeliadi commented Mar 2, 2022

@jkasten2 Hi! Thanks for your suggestion, unfortunately it's still not working. Any other suggestion, please?

Something that maybe it is interesting to point out, depending on where you put the OneSignalNotificationServiceExtension, inside or outside the main target, the build process raises two (inside) or one (outside) errors, always 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead..

@jkasten2
Copy link
Member

@allemanfredi
Copy link
Author

i tried to add the code below but it does not work.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
    end
  end
end

I get 2 errors:

Undefined symbol: vtable for facebook::react::HermesExecutorFactory
Undefined symbol: _OBJC_CLASS_$_RCTInspectorDevServerHelper

@yoannes
Copy link

yoannes commented Jun 15, 2022

#1359 (comment)

After moving OneSignalNotificationServiceExtension inside target I got the 'sharedApplication' is unavailable error and what worked for me was to set the Require Only App-Extension-Safe API to No

image

@jpangan
Copy link

jpangan commented Aug 12, 2022

Which solution worked? I have been in this situation for 2 days now. I tried multiple approaches but still didn't get it. The last approach I tried is this #1360 (comment) but still didn't work for me.

@adapptor-kurt
Copy link

For anyone who comes across this issue, the reason for the linking issue here is that the pods declared at the top level are being inherited by all targets. Move all React Native pod definitions (and any other calls that add pods, like use_flipper!) into the app's target so that the OneSignal target won't try to link those RN dependencies.

@jennantilla
Copy link
Contributor

Hello everyone! Since it has been quite some time since this issue has seen activity, I'm going to close it as stale. Please @ mention me if anyone is still experiencing this on the latest Player Model (4.5.2) or User Model (5.0.5) releases and we'll be happy to give it some fresh eyes. Thanks!

@Faisalnawaz953
Copy link

Faisalnawaz953 commented Jan 9, 2025

Placing

$NotifeeExtension = true
 target 'NotifeeNotificationService' do
   pod 'RNNotifeeCore', :path => '../node_modules/@notifee/react-native/RNNotifeeCore.podspec'
 end

before post_install work for me


require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, '14.0'
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

rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseCrashlytics', :modular_headers => true
pod 'FirebaseInstallations', :modular_headers => true
pod 'GoogleDataTransport', :modular_headers => true
pod 'nanopb', :modular_headers => true
pod 'FirebaseCoreExtension',:modular_headers=>true


target 'MyApp' do
  permissions_path = '../node_modules/react-native-permissions/ios'
  
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways/Permission-LocationAlways.podspec"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse/Permission-LocationWhenInUse.podspec"

  config = use_native_modules!

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

  target 'MyAppTest' do
    inherit! :complete
  end

  pre_install do |installer|
    installer.analysis_result.specifications.each do |spec|
      if spec.name == 'React-Core' || spec.name.start_with?('RCT-Folly')
        spec.resource_bundles = {}  # Prevents privacy-related bundles from being created
      end
    end
  end
  $NotifeeExtension = true
  target 'NotifeeNotificationService' do
    pod 'RNNotifeeCore', :path => '../node_modules/@notifee/react-native/RNNotifeeCore.podspec'
  end
  post_install do |installer|
    # This removes all privacy-related bundle conflicts in React-Core and RCT-Folly
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
       end
    end

    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
  end
 
end


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants