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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With