【问题标题】:sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate insteadsharedApplication' 不可用:在 iOS 上不可用(应用程序扩展) - 在适当的情况下使用基于视图控制器的解决方案
【发布时间】:2018-08-09 01:49:53
【问题描述】:

所以我想做的是从 Firebase 获取当前用户的信息并将其显示在今天的小部件上。为了做到这一点,我必须在guide 之后将 Today 扩展设置为它自己的应用程序。一切都很顺利;但是,当我尝试运行该应用程序时,我从一个完全不同的框架中收到了三个错误消息,该框架与今天的扩展完全无关,它不是框架 IQAudioRecorderController。我在 IQAudioCropperViewController.m 文件中收到此错误:

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

我在网上查了这个原因,是因为框架与扩展不兼容,但问题是,这个框架与我的扩展无关,它也可以选择其他任何框架,为什么是这个。我在网上寻找解决方案,但没有什么是我想要的。除了按照这些说明将扩展名添加到 Firebase 并添加 pod 之外,我没有对应用程序做任何事情,就是这样,然后突然间我从同一个文件中收到了 3 条完全相同的错误消息。我试图清理和构建,但没有任何效果。提前非常感谢您!

Pod 文件:

# 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

【问题讨论】:

  • 请提供您的 podfile
  • 我刚加了

标签: ios swift xcode firebase firebase-authentication


【解决方案1】:

这是由 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 版本的修复程序可以解决此问题!

【讨论】:

    猜你喜欢
    • 2015-05-31
    • 1970-01-01
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    • 1970-01-01
    • 2018-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多