cordova-plugin-inappbrowser: iOS - build fails if using "WKWebViewOnly" preference

Bug Report

Problem

What is expected to happen?

cordova build ios Build success

What does actually happen?

$ cordova build ios
...
** BUILD FAILED **


The following build commands failed:
        CompileC /Users/foo/Library/Developer/Xcode/DerivedData/HelloWorld-euwessldwjxdluatamnrumldwksu/Build/Intermediates.noindex/HelloWorld.build/Debug-iphonesimulator/HelloWorld.build/Objects-normal/x86_64/CDVUIInAppBrowser.o /Users/foo/dev/hello/platforms/ios/HelloWorld/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
xcodebuild: Command failed with exit code 65

Information

Since cordova-ios@5.1.0 and following https://github.com/apache/cordova-ios/pull/715 If you add “WKWebViewOnly” preference, then cordova build fails on using cordova-plugin-inappbrowser

(ping https://github.com/apache/cordova-plugin-inappbrowser/pull/535 & https://github.com/apache/cordova-plugin-inappbrowser/issues/532)

Command or Code

cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add ios
cordova plugin add cordova-plugin-inappbrowser
<<add "WKWebViewOnly" preference into config.xml>>
cordova build ios

Environment, Platform, Device

Version information

Cordova CLI 9.0.0 Cordova Platform iOS (5.1.0) Cordova Plugin cordova-plugin-inappbrowser (3.1.0)

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 19
  • Comments: 53 (2 by maintainers)

Most upvoted comments

yes, its being sent since August, and so far nothing happened

and you can always remove it or fork my repo which is free from the UIWebView code https://github.com/kleeb/cordova-plugin-inappbrowser

<plugin name="cordova-plugin-inappbrowser" spec="https://github.com/kleeb/cordova-plugin-inappbrowser.git" source="git"/>

also don’t forget to upgrade cordova-ios to 5.1.0

an whats more important - this will not work on Phonegap Build

Is there any news on this topic when the fix will be merged ?

@ath0mas is this using the official cordova-plugin-inappbrowser, or another branch of it? Did you have to edit any of the files?

this issue was fully fixed by #584 and released in v3.2.0 so yes I am using the official plugin

Also did you need to include cordova-plugin-wkwebview-engine plugin too?

Yes of course, use of “WKWebViewOnly” preference requires that a WKWebView engine plugin be installed in the Cordova project (e.g. cordova-plugin-wkwebview-engine or cordova-plugin-ionic-webview)

To conclude this issue, I tested the upload of my app to Apple

before using v3.2.0

  • I received the email “App Store Connect: Your app … has one or more issues”

ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs . See https://developer.apple.com/documentation/uikit/uiwebview for more information.

And then using v3.2.0

  • no more mail, no more issue 👍

Perfect job! 🏆 🚀

Can we get this merged and released? This seems important, now that Apple says that it will stop accepting builds containing references to UIWebView.

True, inappbrowser still uses UIWebview in some parts of the code

/Users/vagrant/git/platforms/ios/Ondrowa/Plugins/cordova-plugin-inappbrowser/CDVUIInAppBrowser.h:64:5: error: unknown type name 'CDVUIWebViewDelegate' CDVUIWebViewDelegate* _webViewDelegate; ^ 1 error generated.

further reading: https://ionicframework.com/blog/understanding-itms-90809-uiwebview-api-deprecation/ https://cordova.apache.org/announcements/2019/11/25/cordova-ios-release-5.1.0.html https://github.com/apache/cordova-ios/pull/715

is this using the official cordova-plugin-inappbrowser, or another branch of it? Did you have to edit any of the files?

The latest apache version of inappbrowser includes support for reading the wkwebview flag and is available in version 3.2.0.

See https://github.com/apache/cordova-plugin-inappbrowser/pull/584 for more details on the PR that fixed this issue.

Yep, we are currently experiencing the same issue in our CI environments. Wouldn’t it be more feasible to use a compile-time flag like in https://github.com/apache/cordova-ios/pull/715?

#if WK_WEB_VIEW_ONLY
...
#endif

@kleeb: You might need to remove the references to the CDVUIInAppBrowser file in the plugin.xml too.

“So far” isn’t something I can reliably communicate to my clients. Thanks for the link, I’ll try your repo tomorrow and submit new build to store.

I’m already on 5.1.1 (and using Cordova).

@kleeb fixed my build issue. I did do a grep for UIWebView and did see the following files with some sort of reference to it.

node_modules/cordova-plugin-inappbrowser/tests/tests.js
node_modules/cordova-plugin-inappbrowser/README.md
node_modules/cordova-plugin-inappbrowser/src/ios/CDVWKInAppBrowser.m

The first two should not matter but the 3rd one (CDVWKInAppBrowser.m) has a comment with “UIWebViews”. Do you know if Apple cares if there is any reference at all such as in comments?

I guess if you grep through your www directory and do not find any instances of UIWebView are you good to go?

The deadline has been published: The App Store will no longer accept new apps using UIWebView as of April 2020 and app updates using UIWebView as of December 2020.

https://developer.apple.com/news/?id=12232019b

It seems that it worked. I’ve switched to WKWebViewOnly=true and used the forked inappbrowser from the link provided by @kleeb. The release version compiled without errors and after submitting it to AppStore Connect and processing, I haven’t received the email with submission warnings. For now, this will do, but ideally, it should land in the main plugin.

Thank you!

Problem is not the warning, but that I can’t build at all.

Again, yes, we need to fix the build!! other problems about Apple warnings are not the main concern

Oke, I will have to check how to use @kleeb branch in my Ionic app. Problem is not the warning, but that I can’t build at all.

Pretty much, yes. I’ve made it my habit to always remove all platforms and then add them all again, whenever I change something in config.xml or adding plugins. Most of the time it’s probably unnecessary, but I’ve encountered these inconsistencies so many times in the past, that I’ve just decided it’s easier (and more reliable) for me this way.

But, as @kleeb mentioned, chances are, some of your other plugins might still contain UIWebView references.

Once you submit the build to AppStore Connect for processing, you’ll get an email like this. Screenshot 2019-12-04 at 19 30 42