Search code examples
iosswiftfacebookfbsdk

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

Solution

  • Try to comment OneSignalNotificationServiceExtension target & pod , clean , install and run again