Facebook cocoapods 'sharedApplication' 不可用:iOS 不可用(应用程序扩展)
Facebook cocoapods 'sharedApplication' is unavailable: not available on iOS (App Extension)
我已经通过 cocoapods 安装了 facebook sdk,但出现以下错误:
'sharedApplication' is unavailable: not available on iOS (App
Extension) - Use view controller based solutions where appropriate
instead.
关于 FBSDKCoreKit/FBSDKAppEvents.m
中的第 701 行
UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController;
为什么会发生这种情况,我该如何解决?
播客文件:
# 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
尝试评论 OneSignalNotificationServiceExtension
目标和 pod、清理、安装并再次 运行
这对我有帮助:
Pods 项目 -> select Target 包含此错误 -> Build Settings -> 将 仅需要应用程序扩展安全 API 设置为 否
您可能需要对其他 FB 框架执行相同的操作
我遇到了同样的问题,我解决了
将 require only App-Extension-Safe Api
设置为 no
似乎所有的 facebook pods require only App-Extension-Safe Api
都设置为 yes 所以我必须为所有 xcodeproject,target,all facebook pods
设置 no ,
您可以在重新安装时找到 require only App-Extension-Safe Api in build setting for pods,target,and project
重要提示 pods 它们被重置为是
您可以将以下块添加到您的 Podfile
以编程方式解决此问题。
如果您正在使用 pods,您可以将以下块添加到您的 Podfile
以解决此问题:
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
这会将所有 Pod 项目目标的 require only App-Extension-Safe Api
设置为 No
,应该可以让您的构建成功。
我已经通过 cocoapods 安装了 facebook sdk,但出现以下错误:
'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
关于 FBSDKCoreKit/FBSDKAppEvents.m
中的第 701 行UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController;
为什么会发生这种情况,我该如何解决? 播客文件:
# 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
尝试评论 OneSignalNotificationServiceExtension
目标和 pod、清理、安装并再次 运行
这对我有帮助: Pods 项目 -> select Target 包含此错误 -> Build Settings -> 将 仅需要应用程序扩展安全 API 设置为 否
您可能需要对其他 FB 框架执行相同的操作
我遇到了同样的问题,我解决了
将 require only App-Extension-Safe Api
设置为 no
似乎所有的 facebook pods require only App-Extension-Safe Api
都设置为 yes 所以我必须为所有 xcodeproject,target,all facebook pods
设置 no ,
您可以在重新安装时找到 require only App-Extension-Safe Api in build setting for pods,target,and project
重要提示 pods 它们被重置为是
您可以将以下块添加到您的 Podfile
以编程方式解决此问题。
如果您正在使用 pods,您可以将以下块添加到您的 Podfile
以解决此问题:
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
这会将所有 Pod 项目目标的 require only App-Extension-Safe Api
设置为 No
,应该可以让您的构建成功。