cordova-plugin更新,包含UIWebView,无法上线

最近有新的ionic项目,想将app上到testflight去测试推送,结果就出现了一系列代码包含UIWebView,导致testflight无法上。

我首先是terminal,去到项目目录下,执行

grep -r UIWebView .

发现如下插件包含:

./XXXX/Classes/MainViewController.m:- (UIWebView*) newCordovaViewWithFrame:(CGRect)bounds
Binary file ./XXXX/Plugins/cordova-plugin-alipay-v2/AlipaySDK.framework/AlipaySDK matches
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.h:    #import 
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.h:@interface CDVUIInAppBrowserViewController : UIViewController {
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.h:    CDVUIWebViewDelegate* _webViewDelegate;
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.h:@property (nonatomic, strong) IBOutlet UIWebView* webView;
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVWKInAppBrowser.m:    // Work around a bug where the first time a PDF is opened, all UIWebViews
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:    // UIWebView options
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:- (void)webViewDidStartLoad:(UIWebView*)theWebView
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:- (void)webViewDidFinishLoad:(UIWebView*)theWebView
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:        _webViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:self];
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:    self.webView = [[UIWebView alloc] initWithFrame:webViewBounds];
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:#pragma mark UIWebViewDelegate
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:- (void)webViewDidStartLoad:(UIWebView*)theWebView
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:- (void)webViewDidFinishLoad:(UIWebView*)theWebView
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:    // Work around a bug where the first time a PDF is opened, all UIWebViews
./XXXX/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m:- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error

./CordovaLib/Classes/Public/CDVCommandDelegateImpl.m:    //    function (possible since UIWebViewDelegate callbacks can be synchronous).
./CordovaLib/Classes/Public/CDVUserAgentUtil.m:            UIWebView* sampleWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
./CordovaLib/Classes/Public/CDVUserAgentUtil.m:    // TODO: We should figure out how to update the user-agent of existing UIWebViews when this happens.
./CordovaLib/Classes/Public/CDVUserAgentUtil.m:    // Setting the UserAgent must occur before a UIWebView is instantiated.
./CordovaLib/Classes/Public/CDVUserAgentUtil.m:    // Except! When a PDF is loaded, all currently active UIWebViews reload their
./CordovaLib/Classes/Public/CDVWebViewEngineProtocol.h:#define kCDVWebViewEngineUIWebViewDelegate @"kCDVWebViewEngineUIWebViewDelegate"
./CordovaLib/Classes/Public/CDVCommandDelegate.h:// Returns the User-Agent of the associated UIWebView.
./CordovaLib/Classes/Public/CDVViewController.m:        defaultWebViewEngineClass = @"CDVUIWebViewEngine";
./CordovaLib/Classes/Public/CDVViewController.m:        // if a webView engine returns nil (not supported by the current iOS version) or doesn't conform to the protocol, or can't load the request, we use UIWebView
./CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m:#define CDVWebViewNavigationTypeLinkClicked UIWebViewNavigationTypeLinkClicked
./CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m:#define CDVWebViewNavigationTypeOther UIWebViewNavigationTypeOther
./CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m:            // only allow-intent if it's a UIWebViewNavigationTypeLinkClicked (anchor tag) OR
./CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m:            // it's a UIWebViewNavigationTypeOther, and it's an internal link
./CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.h:#define CDVWebViewNavigationType UIWebViewNavigationType
./CordovaLib/Classes/Private/Plugins/CDVLocalStorage/CDVLocalStorage.m:@property (nonatomic, readwrite, weak) id  webviewDelegate;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.h:#import "CDVUIWebViewEngine.h"
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.h:@interface CDVUIWebViewNavigationDelegate : NSObject 
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:#import "CDVUIWebViewDelegate.h"
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:@implementation CDVUIWebViewDelegate
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (id)initWithDelegate:(NSObject *)delegate
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (BOOL)isPageLoaded:(UIWebView*)webView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (BOOL)isJsLoadTokenSet:(UIWebView*)webView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (void)setLoadToken:(UIWebView*)webView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (NSString*)evalForCurrentURL:(UIWebView*)webView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (void)pollForPageLoadStart:(UIWebView*)webView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (void)pollForPageLoadFinish:(UIWebView*)webView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:                        NSError* error = [[NSError alloc] initWithDomain:@"CDVUIWebViewDelegate" code:1 userInfo:errorDictionary];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (void)webViewDidStartLoad:(UIWebView*)webView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (void)webViewDidFinishLoad:(UIWebView*)webView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m:- (void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.h:@interface CDVUIWebViewEngine : CDVPlugin 
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.h:@property (nonatomic, strong, readonly) id  uiWebViewDelegate;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m:#import "CDVUIWebViewNavigationDelegate.h"
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m:@implementation CDVUIWebViewNavigationDelegate
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m:- (void)webViewDidStartLoad:(UIWebView*)theWebView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m:- (void)webViewDidFinishLoad:(UIWebView*)theWebView
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m:- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m:- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h:@interface CDVUIWebViewDelegate : NSObject {
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h:    __weak NSObject * _delegate;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h:- (id)initWithDelegate:(NSObject *)delegate;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:#import "CDVUIWebViewEngine.h"
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:#import "CDVUIWebViewDelegate.h"
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:#import "CDVUIWebViewNavigationDelegate.h"
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:@interface CDVUIWebViewEngine ()
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:@property (nonatomic, strong, readwrite) id  uiWebViewDelegate;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:@property (nonatomic, strong, readwrite) CDVUIWebViewNavigationDelegate* navWebViewDelegate;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:@implementation CDVUIWebViewEngine
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:        self.engineWebView = [[UIWebView alloc] initWithFrame:frame];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:        NSLog(@"Using UIWebView");
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    UIWebView* uiWebView = (UIWebView*)_engineWebView;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    if ([self.viewController conformsToProtocol:@protocol(UIWebViewDelegate)]) {
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:        self.uiWebViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:(id )self.viewController];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:        self.navWebViewDelegate = [[CDVUIWebViewNavigationDelegate alloc] initWithEnginePlugin:self];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:        self.uiWebViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:self.navWebViewDelegate];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    NSString* ret = [(UIWebView*)_engineWebView stringByEvaluatingJavaScriptFromString:javaScriptString];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    [(UIWebView*)_engineWebView loadRequest:request];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    [(UIWebView*)_engineWebView loadHTMLString:string baseURL:baseURL];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    return [[(UIWebView*)_engineWebView request] URL];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    UIWebView* uiWebView = (UIWebView*)_engineWebView;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    NSString* decelerationSetting = [settings cordovaSettingForKey:@"UIWebViewDecelerationSpeed"];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    UIWebView* uiWebView = (UIWebView*)_engineWebView;
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:    id  uiWebViewDelegate = [info objectForKey:kCDVWebViewEngineUIWebViewDelegate];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:        [uiWebViewDelegate conformsToProtocol:@protocol(UIWebViewDelegate)]) {
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:        self.uiWebViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:(id )uiWebViewDelegate];
./CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m:// Both WKWebView and UIWebView implement the below:

发现1,插件cordova-plugin-alipay-v2

发现2,插件cordova-plugin-inappbrowser

发现3,CDVUIWebViewEngine,CDVUIWebViewDelegate,CDVUIWebViewNavigationDelegate的.h,.m文件都有

发现4 , CDVUserAgentUtil.m也有

解决如下:

解决1.

找到https://github.com/JayzeeHuang/cordova-plugin-alipay-v2/tree/JayzeeHuang-patch-1/www。下载下来(解压,更名为cordova-plugin-alipay-v2,即可拖入项目),图为下载下来的内容,哈哈哈

放入项目文件node_modules,plugins中 然后将ios文件删除,重新 ionic cordova prepare ios即可获得最新的code数据~~

 

解决2:

在package.json文件中修改 cordova-plugin-inappbrowser的版本(ps:我用3.2.0居然还是有,所以我放弃了3.2.0)

    "cordova-plugin-inappbrowser": "^4.1.0",

然后重新 npm install即可。

2021.3.2更新:请添加wkwebview去fix一些issue:

cordova plugin add https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix


解决3:

其实2已经更新了,我不知道为啥3的代码居然还存在,反正我的项目是用不到的,所以我自己手动删除里面的关于UIWebView的代码了,直接删除文件会报错,毕竟有关联的其他未包含UIWebView并且不使用的文件,我反正选择清除吧。对于这个解决方法我是不满意的,但是目前来讲,只能做到这样了。

找到目录下文件:

cordova-plugin更新,包含UIWebView,无法上线_第1张图片

下图对应的六个文件都不要,大致改成如下

cordova-plugin更新,包含UIWebView,无法上线_第2张图片

解决4,这个文件也改:

cordova-plugin更新,包含UIWebView,无法上线_第3张图片

原本是:

cordova-plugin更新,包含UIWebView,无法上线_第4张图片

红色的框都是需要删除的,结果如下:

cordova-plugin更新,包含UIWebView,无法上线_第5张图片

就可以啦

 

 

 

 

 

 

你可能感兴趣的:(ionic日志,前端)