我的应用和操作扩展都需要 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 API
为NO
(对于我的应用程序和扩展程序)。
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