Pav*_*hav 3 xcode ios cocoapods swift share-extension
我在共享扩展中使用以下 pod。编译器不断显示错误:sharedApplication' 不可用:在 iOS(应用程序扩展)上不可用 - 在适当的情况下使用基于视图控制器的解决方案。在 [UIApplication sharedApplication] 行上的每个库中
我在 Share Extension 目标中安装了所有库。
我的项目中有四个目标,包括 Share-Extension,并且我为每个目标设置了“AppExtension flag is NO”。还是出现错误。
Target -> Build Settings -> Require Only AppExtension-Safe API -> NO
我的播客文件:
platform :ios, '11.2'
def shared_pods
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
pod 'XMPPFramework', :git => "https://github.com/robbiehanson/XMPPFramework.git", :branch => 'master'
pod 'MBProgressHUD'
pod 'GoogleMaps'
pod 'GooglePlaces'
pod 'AccountKit'
pod 'Alamofire', '~> 4.5'
pod 'AlamofireImage', '~> 3.3'
pod 'SVProgressHUD'
pod 'SDWebImage', '~> 4.1.1'
pod 'AWSS3', '~> 2.6.0'
pod 'Fabric'
pod 'Crashlytics'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'ReverseExtension'
end
target ‘Production' do
shared_pods
end
target ‘Development’ do
shared_pods
end
target ‘Testing’ do
shared_pods
end
Run Code Online (Sandbox Code Playgroud)
小智 15
我在这里找到了一个可行的解决方案:https://ahbou.org/post/169786332682/shared-is-unavailable-use-view-controller-based
\n听起来是这样的:
\n选择左侧菜单中的 Pods 项目
\n选择与目标列表中的扩展不兼容的\xe2\x80\x99s Pod
\n选择构建设置
\n将“仅需要应用程序扩展安全 API”设置为“否”
\n在我的 Swift Packages 中升级到 Xcode 13 后开始遇到这个问题。SPM 没有与 pod 相同的目标成员资格选项,因此 Uday 的答案对我来说不太合适。这个问题本质上是现在(显然?)为所有可用目标编译 SPM 包,无论它们是否实际链接。因此,如果你的代码不会在某些地方工作,你从来没有打算使用它,你根本无法建立自己的代码。
我的解决方案是 fork 包并将有此问题的类标记为在扩展中不可用:
NS_EXTENSION_UNAVAILABLE("xxxx not supported in extensions (deprecated use of UIApplication shared)")
@interface xxxx : UIView
...
Run Code Online (Sandbox Code Playgroud)
或者等效地在 Swift 中:
@available(iOSApplicationExtension, unavailable)
class xxxx {
...
Run Code Online (Sandbox Code Playgroud)
您还可以将这些可用性宏应用于特定的函数/变量,但将它放在整个类上对我来说侵入性较小,因为我从来没有打算在扩展中使用这些库。
mat*_*att -3
问题是 pod 是用 Swift 的早期版本(2?)编写的,而您尝试在更新的版本下使用它。sharedApplication变成了shared很久以前的事了。
您需要获取 pod 的更新版本(如果可能)。
| 归档时间: |
|
| 查看次数: |
7548 次 |
| 最近记录: |