react-native-onesignal icon indicating copy to clipboard operation
react-native-onesignal copied to clipboard

Undefined symbol: _OBJC_CLASS_$_RCTInspectorDevServerHelper

Open allemanfredi opened this issue 3 years ago • 10 comments

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

allemanfredi avatar Feb 03 '22 13:02 allemanfredi

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" :(

mdeliadi avatar Feb 03 '22 16:02 mdeliadi

@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.

jkasten2 avatar Feb 11 '22 23:02 jkasten2

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 avatar Feb 14 '22 15:02 mdeliadi

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

mdeliadi avatar Feb 28 '22 16:02 mdeliadi

@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 https://github.com/OneSignal/react-native-onesignal/issues/1360#issuecomment-1055983842) but not sure exactly why it is required in this scenario when hermes_enabled is set to true.

jkasten2 avatar Mar 01 '22 23:03 jkasten2

@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..

mdeliadi avatar Mar 02 '22 09:03 mdeliadi

@mdeliadi For the "'sharedApplication' is unavailable" issue see the following:

  • https://stackoverflow.com/a/56789751
  • https://github.com/OneSignal/OneSignal-iOS-SDK/issues/965

jkasten2 avatar Mar 23 '22 09:03 jkasten2

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

allemanfredi avatar May 17 '22 12:05 allemanfredi

https://github.com/OneSignal/react-native-onesignal/issues/1359#issuecomment-1055985717

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

yoannes avatar Jun 15 '22 15:06 yoannes

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 https://github.com/OneSignal/react-native-onesignal/issues/1360#issuecomment-1044787027 but still didn't work for me.

jpangan avatar Aug 12 '22 08:08 jpangan

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.

adapptor-kurt avatar Jan 06 '23 03:01 adapptor-kurt

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!

jennantilla avatar Feb 03 '24 01:02 jennantilla