4

I need the Facebook SDK in both my app and my action extension. I use Cocoapods 1.4.0, Swift 4 and Xcode 9.2. I'm having this error message coming from the FBSDKCoreKit:

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

I've already read a lot of answers, on SOF and Github mainly. I tried a lot of suggestions. But I did not make it work.

My current Podfile:

source 'https://github.com/CocoaPods/Specs.git'
workspace 'MyApp'
use_frameworks!
platform :ios, '10.0'
inhibit_all_warnings!

def my_pods
    pod 'FBSDKCoreKit'
    pod 'FBSDKLoginKit'
    pod 'FBSDKShareKit'

end

target 'MyApp' do
    my_pods
end

target 'MyAppExtension' do
    my_pods
end

What I tried:

1) set Require Only App-Extension-Safe API to NO (both for my app and the extension).

2) add this to my podfile:

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        if target.name == "Pods-MyAppExtension-FBSDKCoreKit"
            target.build_configurations.each do |config|
                //I tried both these lines
                config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'AF_APP_EXTENSIONS=1']
                config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
            end
        end
    end
end
Marie Dm
  • 2,637
  • 3
  • 24
  • 43
  • Have you solved the issue? I've the same one :( – Kostya Vyrodov Apr 02 '19 at 11:47
  • 1
    @KostyaVyrodov no I use the static library instead and didn't try again since then. – Marie Dm Apr 02 '19 at 14:24
  • 1
    I think Facebook has to solve this issue with release new SDK, I have the same issue which SDK conflict with OneSignal extension so far. What I will try ( download old version of FBSDK and send a bug report regarding this issue ) – Onder OZCAN Jul 09 '19 at 14:06

1 Answers1

0

only as documentation if others arrive here:

using SPM and FB SDK 11.0 AND Xcode 12.x it works using " " AND Xcode 13.beta for iOS13 fails:

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

PS

it's a shame using objC in 2021... :(

and ridiculous using "SWFT" Package manager containing objC, :(

ingconti
  • 10,876
  • 3
  • 61
  • 48