iOS Action 扩展 Cocoapods Podfile FBSDKCoreKit 'sharedApplication' 不可用

标签 ios swift xcode cocoapods podfile

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

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



我已经阅读了很多答案,主要是在 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

最佳答案

仅作为其他人到达这里时的文件:
使用 SPM 和 FB SDK 11.0 AND Xcode 12.x 它可以工作
使用 ""AND Xcode 13.beta for iOS13 失败:
'sharedApplication' 不可用:在 iOS(应用扩展)上不可用 - 在适当的情况下使用基于 View Controller 的解决方案。
聚苯乙烯
在 2021 年使用 objC 真是太可惜了... :(
使用包含 objC 的“SWFT”包管理器可笑,:(

关于iOS Action 扩展 Cocoapods Podfile FBSDKCoreKit 'sharedApplication' 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48570267/

相关文章:

objective-c - 如何在 NSNumberFormatter 的输出上强制使用符号字符

ios - 如何查看手机时间格式是否设置为24小时制?

ios - 系统库中 iOS 上的 EXC_BAD_ACCESS

objective-c - GCRectMake 的 iOS 错误 - 将 'int' 发送到不兼容类型 'CGRect' 的参数(又名 'struct CGRect')

ios - 下一个轨道AVPlayer如何

ios - 从 Firebase 保存大量数据

ios - 进行模态转场时出现错误的presentingViewController(使用ECSlidingViewController)

xcode - Unity 项目的 iOS 模拟器未运行

Objective-C 的 #import 语句 - 不会在文件夹中导入文件

ios - 来自两个容器 View 的不同 subview Controller 中的不同导航栏按钮项目?