所以我想做的是从 Firebase 获取当前用户的信息并将其显示在今天的小部件上。为了做到这一点,我必须按照这个 guide 将 Today 扩展设置为它自己的应用程序。 .一切顺利;但是,当我尝试运行该应用程序时,我收到了来 self 正在使用的完全不同的框架的三个错误消息,这与今天的扩展完全无关,它不是框架 IQAudioRecorderController。我在 IQAudioCropperViewController.m 文件中收到此错误:
“sharedApplication' 不可用:在 iOS 上不可用(应用程序扩展)- 在适当的地方使用基于 View Controller 的解决方案。”
我在网上查了一下原因,是因为框架不兼容扩展,但事实是,这个框架和我的扩展无关,它也可以选择任何其他框架,为什么是这个。我在网上寻找解决方案,但没有什么是我想要的。除了按照这些说明将扩展添加到 Firebase 并添加 pod 之外,我没有对应用程序做任何事情,就是这样,然后突然间我从同一个文件中收到了 3 条完全相同的错误消息。我试过清理和构建但没有任何效果。非常感谢您!
播客文件:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'ShareExtension' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ShareExtension!
end
target 'myApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'JSQMessagesViewController', '7.3.3'
pod 'IDMPhotoBrowser'
pod 'Firebase/Database'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'MBProgressHUD'
pod 'IQAudioRecorderController'
pod 'SinchRTC'
pod 'OneSignal'
# Pods for myApp
target 'myAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'myAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
target 'SiriIntents' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for SiriIntents
end
target 'SiriIntentsUI' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for SiriIntentsUI
end
target 'TodayExtension' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'Firebase/Database'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
# Pods for TodayExtension
end
最佳答案
这是由 Firebase pod 中的以下代码引起的:
[UIApplication sharedApplication]
FIRAuth.m
在许多其他类中有这段代码。 iOS 扩展的架构略有不同,它们无法调用 sharedApplication
。
似乎 Firebase 并未正式支持 iOS 中的扩展。我从这个 GitHub issue 得到了这些信息.也许来自 Firebase 的人也可以在这里确认这一点。我很惊讶我们在创建诸如 Today 小部件之类的扩展时不能使用 Firebase SDK。
我唯一的解决方法是通过以下方式恢复到早期版本的 Firebase:
pod 'Firebase', '4.9.0'
这使用 4.9.0 版的 Firebase SDK,不会产生编译器错误。
检查 Stackoverflow thread更多细节。总之,针对 5.2.x 版本的修复解决了这个问题!
关于ios - sharedApplication' 不可用 : not available on iOS (App Extension) - Use view controller based solutions where appropriate instead,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49042154/