我的项目中有 Objective C
和 Swift
Pod。
pod 'WBWebViewConsole', '~> 1.0.1'
use_frameworks!
pod 'XWebView', '~>0.9.5’
pod 'Starscream', '~> 1.1.3'
因为 swift POD(XWebView、Starscream)只能添加为我必须使用的框架 use_frameworks!
但这使得所有 POD 都成为框架,包括 Objective-C POD(WBWebViewConsole)。
但这会导致 Objective-C POD 出现问题,但我不打算将 Objective-C POD 作为框架。
那么我是否可以忽略几个 POD 不被转换为框架?
谢谢。
更新:
如何重现问题?
问题出在 POD WBWebViewConsole
运行 attached project在任何具有互联网连接的 iOS 8+ 设备中,因为它从谷歌驱动器加载 html 文档。
在 html 文档中……点击 General/Info/Warning/Debug/Error Log
每当您单击上述任何按钮时,您都会在 html 页面上显示一些文本......
该库是关于捕获在 html 页面中生成的日志......
每当你点击按钮时,除了在 html 页面中显示一些文本之外,我正在编写一些登录背景。
现在点击按钮get logs ...然后在Xcode IDE中查看日志...您将看到所有以html格式生成的控制台日志
Get logs-> 是一个 super 强加在 webview 上的原生按钮..这个库让我们从 wkwebview 读取控制台日志 ..
现在在 POD 中 你取消注释以下行
use_frameworks!
pod 'PLCrashReporter'
pod 'XWebView', '~> 0.9.5’
然后安装 pod
然后将下面的代码粘贴到ViewController之上
import WBWebViewConsole
这是 project重现问题所需的所有更改均未注释所有这些
现在您在设备上运行该项目并单击 html 页面中的一些按钮并单击获取日志您看不到在 html 页面中生成的评论
具体来说,WBWKWebView 中实现的以下委托(delegate)方法不会被触发。
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
- (void)wb_evaluateJavaScript:(NSString *)javaScriptString completionHandler:(void (^)(NSString *, NSError *))completionHandler
但是在创建 WBWKWebView
实例并加载 URL 时,该类的所有必要委托(delegate)都被解雇了。
上面的代表应该在点击 html 页面中的按钮写入日志时触发
最佳答案
您可以覆盖 use_frameworks!
并将所有 pod 安装为静态,除了您选择作为框架的 pod
在 Podfile 中使用 use_frameworks!
并在文件末尾添加
dynamic_frameworks = ['aaa','bbb'] # <- swift libraries names
# Make all the other frameworks into static frameworks by overriding the static_framework? function to return true
pre_install do |installer|
installer.pod_targets.each do |pod|
if !dynamic_frameworks.include?(pod.name)
puts "Overriding the static_framework? method for #{pod.name}"
def pod.static_framework?;
true
end
def pod.build_type;
Pod::BuildType.static_library
end
end
end
end
关于ios - 使用_框架!仅适用于某些 pod 或 swift pod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37388126/