sharedApplication'不可用:iOS上不可用(App Extension) - 在适当的情况下使用基于视图控制器的解决方案

时间:2018-03-01 03:26:30

标签: ios swift xcode firebase firebase-authentication

所以我要做的是从Firebase获取当前用户的信息并在今天的小部件上显示。为了做到这一点,我必须按照此guide设置今天的扩展程序,就像它自己的应用程序一样。一切顺利;但是,当我尝试运行应用程序时,我从一个完全不同的框架中得到了三条错误消息,我正在使用它与今天的扩展名无关,它是Framework IQAudioRecorderController。我在IQAudioCropperViewController.m文件中收到此错误:

" sharedApplication'不可用:iOS上不可用(App Extension) - 在适当的情况下使用基于视图控制器的解决方案。"

我已经在网上查找了这个原因,因为该框架与扩展程序不兼容,但问题是,这个框架与我的扩展程序无关,它可以选择任何其他框架也是如此,为什么这个。我已经在网上寻找解决方案,没有什么是我想要的。我没有对该应用做任何事情,除了按照这些说明将扩展程序添加到Firebase并添加了pod之后,我突然间从同一个文件中获得了3个完全相同的错误消息。我已经尝试过清洁和构建,但没有任何工作。非常感谢你!

Podfile:

# 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

1 个答案:

答案 0 :(得分:1)

这是由Firebase pod中的以下代码引起的:

  • [UIApplication sharedApplication]

FIRAuth.m在其他类中包含此代码。 iOS扩展程序的架构略有不同,调用sharedApplication不是他们可以做的事情。

似乎Firebase没有正式支持iOS中的扩展程序。我从这个GitHub issue获得了这些信息。也许来自Firebase的人也可以在这里确认一下。我很惊讶在创建今日小部件等扩展时我们无法使用Firebase SDK。

我唯一的解决方法是通过以下方式恢复到早期版本的Firebase:

pod 'Firebase', '4.9.0'

这使用4.9.0版本的Firebase SDK,但不会产生编译错误。

检查Stackoverflow thread以获取更多详细信息。总之,修复程序针对解决此问题的5.2.x版本!