4

我的应用和操作扩展都需要 Facebook SDK。我使用 Cocoapods 1.4.0、Swift 4 和 Xcode 9.2。我收到来自以下的错误消息FBSDKCoreKit

'sharedApplication' 不可用:在 iOS 上不可用(应用程序扩展) - 在适当的情况下使用基于视图控制器的解决方案。

我已经阅读了很多答案,主要是关于 SOF 和 Github。我尝试了很多建议。但我没有让它工作。

我当前的 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

我尝试了什么

1)设置Require Only App-Extension-Safe APINO(对于我的应用程序和扩展程序)。

2) 将此添加到我的 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
4

1 回答 1

0

仅当其他人到达这里时作为文件:

使用 SPM 和 FB SDK 11.0 AND Xcode 12.x 它使用“” AND Xcode 13.beta for iOS13 失败:

'sharedApplication' 不可用:在 iOS 上不可用(应用程序扩展) - 在适当的情况下使用基于视图控制器的解决方案。

附言

在 2021 年使用 objC 真可惜... :(

使用包含 objC 的“SWFT”包管理器很可笑,:(

于 2021-08-12T10:42:32.450 回答