Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook cocoapods 'sharedApplication' is unavailable: not available on iOS (App Extension)

I have installed the facebook sdk via cocoapods but I get the below error:

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

relating to line 701 in FBSDKCoreKit/FBSDKAppEvents.m

UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController;

Why is this happening and how do I resolve it? podfile:

   # Uncomment the next line to define a global platform for your 
 project
 # platform :ios, '9.0'

 target 'testapp' do
# Comment the next line if you're not using Swift and don't want to use dynamic 

frameworks
  use_frameworks!

  # Pods for testapp

pod 'FLAnimatedImage', '~> 1.0'
pod 'SDWebImage', '~> 4.0'
pod 'FacebookLogin'
pod 'FacebookShare'
pod 'FacebookCore'

 pod 'OneSignal', '>= 2.5.2', '< 3.0'


  target 'testappTests' do
    inherit! :search_paths
    # Pods for testing
  end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignal', '>= 2.5.2', '< 3.0'
end

  target 'testappUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end
like image 487
MattBlack Avatar asked Jan 05 '18 23:01

MattBlack


2 Answers

You can add the following block to your Podfile to address this programatically.

If you are using pods you can add the following block to your Podfile to address this issue:

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

This will set the require only App-Extension-Safe Api to No for all pod project targets and should allow your builds to succeed.

like image 152
Michael Prothero Avatar answered Nov 16 '22 20:11

Michael Prothero


That's what helped me: Pods project -> select Target which contains this error -> Build Settings -> set Require Only App-Extension-Safe API to No

You might probably have to do the same for other FB frameworks

like image 21
Jack Stroganov Avatar answered Nov 16 '22 19:11

Jack Stroganov