xcode Pod 更新后编译时出现错误“'sharedApplication' 不可用:iOS 上不可用(应用程序扩展)....”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32031071/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:40:47  来源:igfitidea点击:

Error "'sharedApplication' is unavailable: not available on iOS (App Extension)...." when compiling after pod update

iosxcodebolts-framework

提问by Franck

Hi have a projets(including app extension) using cocoapods. (with Parse, Bolts, etc library).

嗨,有一个使用 cocoapods 的项目(包括应用程序扩展)。(使用 Parse、Bolts 等库)。

All work fine before (using bolts 1.1.5 library), but, when i've run a pod update (Bolts 1.2.0), I now get some errors:

之前一切正常(使用 bolts 1.1.5 库),但是,当我运行 pod 更新(Bolts 1.2.0)时,我现在遇到一些错误:

"/Volumes/project 2/Pods/Bolts/Bolts/iOS/BFAppLinkNavigation.m:100:29: 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead."

“/Volumes/project 2/Pods/Bolts/Bolts/iOS/BFAppLinkNavigation.m:100:29: 'sharedApplication' 不可用:在 iOS(应用程序扩展)上不可用 - 在适当的地方使用基于视图控制器的解决方案。”

Any Idea how to solve this?

任何想法如何解决这个问题?

回答by trojanfoe

Cocoapods are very useful (I'm sure), however they are designed to work with Apps, not App Extensions, and ultimately you lose control of the features they introduce during an update, so you will need to be more judicial about what versions of libraries you do use, based on the APIs they utilize.

Cocoapods 非常有用(我敢肯定),但是它们旨在与应用程序一起使用,而不是应用程序扩展程序,并且最终您将失去对它们在更新期间引入的功能的控制,因此您需要更加判断哪些版本的您使用的库,基于它们使用的 API。

In the case of Bolts 1.2.0, it's obviously decided to use sharedApplication, thus making it unsuitable for use in an App Extension.

在 Bolts 1.2.0 的情况下,显然决定使用sharedApplication,因此不适合在 App Extension 中使用。

So you will need to start using the libraries in source form, perhaps using git submodulefor each one, that will allow you to update them when upstream is updated.

因此,您需要开始以源代码形式使用这些库,也许git submodule对每个库都使用,这将允许您在更新上游时更新它们。

回答by Jibeex

That is a problem related to the settings of Cocoapods projects

那是与Cocoapods项目的设置有关的问题

You can probably find the answer here

你或许可以在这里找到答案

UIApplication.sharedApplication not available

UIApplication.sharedApplication 不可用

回答by Paradise

Just refer to this, which will help you out:

只要参考这个,它会帮助你:

https://github.com/AFNetworking/AFNetworking/issues/2119

https://github.com/AFNetworking/AFNetworking/issues/2119

回答by Franck

I've fixed this by downgrading cocoapods to 0.35.2

我通过将 cocoapods 降级到 0.35.2 解决了这个问题

If you have a more clean solution, i'm open!

如果您有更干净的解决方案,我很乐意!