react-native-share-menu icon indicating copy to clipboard operation
react-native-share-menu copied to clipboard

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

Open scgough opened this issue 4 years ago • 4 comments

Hi I know something similar to this has been discussed in the past but none of the fixes I've found seem to hold an answer!

Whenever I build my app I see the error in the RCTKeyCommans.m file: 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

System Info:

RN: 0.64.2 React: 17.0.2 XCode: 13.1 macOS: 11.6

The share extension has been working without issue and a recent RN upgrade (0.63 => 0.64) has seemingly broken it.

The podfile has the following added:

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

and target for the share extension is like so:

target 'myShareExtension' do
  config = use_native_modules!
  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => false
  )

  pod 'RNShareMenu', :path => '../node_modules/react-native-share-menu'
end

Any advice would be appreciated!

scgough avatar Nov 30 '21 18:11 scgough

Me too , there is no good way

sprint-zhang avatar Dec 20 '21 06:12 sprint-zhang

I did get this to work in the end.

I had further commands in the target.build_configurations.each do |config| loop and the important thing to note is that the APPLICATION_EXTENSION_API_ONLY has to be 1st.

scgough avatar Dec 20 '21 08:12 scgough

Still having this issue.. any news on this?

garridio85 avatar Mar 01 '22 04:03 garridio85

In my case, I have included ReactShareViewController.swift except ShareViewController.swift , so thats solved my build issue

Buwaneka-Sumanasekara avatar Mar 24 '22 13:03 Buwaneka-Sumanasekara