question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting WKWebViewOnly causes `cordova platform add ios` to fail

See original GitHub issue

Bug Report

Problem

When setting WKWebViewOnly to true as an iOS platform preference (see https://github.com/apache/cordova-ios/pull/715), trying to run cordova platform add ios fails when the project does not have existing iOS as an existing platform.

What is expected to happen?

The command should succeed, and WKWebViewOnly should control the setting of WK_WEB_VIEW_ONLY in CordovaLib/CordovaLib.xcodeproj/project.pbxproj.

What does actually happen?

The command fails with the following error:

ENOENT: no such file or directory, open '/Users/ross/repos/my-project/platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj'

Information

Our build process removes the platforms and plugins directories prior to each build to ensure a clean slate for building. When adding the WKWebViewOnly preference, this causes the build to fail.

It seems like if iOS is already added as a platform when the WKWebViewOnly preference is added, the error does not occur.

The error not occur if the WKWebViewOnly preference is removed.

After I receive the error, I can see that the file platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj does indeed exist. So it seems like there might be some race condition where the project is trying to be modified before it is fully created?

Command or Code

I created an empty Cordova project that demonstrates the issue: https://github.com/l3ender/hello-cordova. Clone and follow steps in readme to reproduce.

If you have an existing project, you should be able to reproduce with the following:

rm -rf platforms/ plugins/
cordova platform add ios --verbose

Output from the above command:

-> cordova platform add ios --verbose
No scripts found for hook "before_platform_add".
Using cordova-fetch for cordova-ios@^5.1.0
Removing "cordova-" prefix from cordova-ios
Adding ios project...
PlatformApi successfully found for platform ios
Creating Cordova project for the iOS platform:
	Path: platforms/ios
	Package: com.example.hello
	Name: HelloWorld
Copying iOS template project to /Users/ross/repos/hello-cordova/platforms/ios
iOS project created with cordova-ios@5.1.0
Checking for any plugins added to the project that have not been installed in ios platform
No differences found between plugins added to project and installed in ios platform. Continuing...
PlatformApi successfully found for platform ios
Generating platform-specific config.xml from defaults for iOS at /Users/ross/repos/hello-cordova/platforms/ios/HelloWorld/config.xml
Merging project's config.xml into platform-specific iOS config.xml
Merging and updating files from [www, platforms/ios/platform_www] to platforms/ios/www
  mkdir platforms/ios/www/cordova-js-src
  copy  platforms/ios/platform_www/cordova-js-src/.eslintrc.yml platforms/ios/www/cordova-js-src/.eslintrc.yml (new file)
  copy  platforms/ios/platform_www/cordova-js-src/exec.js platforms/ios/www/cordova-js-src/exec.js (new file)
  copy  platforms/ios/platform_www/cordova-js-src/platform.js platforms/ios/www/cordova-js-src/platform.js (new file)
  mkdir platforms/ios/www/cordova-js-src/plugin
  mkdir platforms/ios/www/cordova-js-src/plugin/ios
  copy  platforms/ios/platform_www/cordova-js-src/plugin/ios/console.js platforms/ios/www/cordova-js-src/plugin/ios/console.js (new file)
  copy  platforms/ios/platform_www/cordova-js-src/plugin/ios/logger.js platforms/ios/www/cordova-js-src/plugin/ios/logger.js (new file)
  copy  platforms/ios/platform_www/cordova.js platforms/ios/www/cordova.js (updated file)
  copy  www/css/index.css platforms/ios/www/css/index.css (updated file)
  copy  www/js/index.js platforms/ios/www/js/index.js (updated file)
Current launch storyboard undefined
Not changing launch storyboard setting in info plist.
Wrote out iOS Bundle Version "1.0.0" to /Users/ross/repos/hello-cordova/platforms/ios/HelloWorld/HelloWorld-Info.plist
No need to update build settings for launch storyboard support.
Set PRODUCT_BUNDLE_IDENTIFIER to com.example.hello.
Set WK_WEB_VIEW_ONLY.
ENOENT: no such file or directory, open '/Users/ross/repos/hello-cordova/platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj'
Error: ENOENT: no such file or directory, open '/Users/ross/repos/hello-cordova/platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj'
    at Object.openSync (fs.js:440:3)
    at Object.readFileSync (fs.js:342:35)
    at pbxProject.parseSync (/Users/ross/repos/hello-cordova/node_modules/xcode/lib/pbxProject.js:61:28)
    at handleBuildSettings (/Users/ross/repos/hello-cordova/platforms/ios/cordova/lib/prepare.js:333:19)
    at updateProject (/Users/ross/repos/hello-cordova/platforms/ios/cordova/lib/prepare.js:234:12)
    at /Users/ross/repos/hello-cordova/platforms/ios/cordova/lib/prepare.js:59:20
    at _fulfilled (/Users/ross/repos/hello-cordova/node_modules/q/q.js:854:54)
    at /Users/ross/repos/hello-cordova/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/Users/ross/repos/hello-cordova/node_modules/q/q.js:816:13)
    at /Users/ross/repos/hello-cordova/node_modules/q/q.js:570:49

Environment, Platform, Device

  • Mac OSX 10.15.1 (Catalina) with latest Xcode (11.2.1).
  • cordova-ios 5.1.0.

Version information

-> cordova -v
9.0.0 (cordova-lib@9.0.1)
-> npm -v
6.12.1
-> node -v
v12.13.1

Checklist

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
davutengincommented, May 5, 2020

cordova platform add ios@5.1.1 solved my problem.

2reactions
vitaliykoziycommented, Nov 28, 2019

Looks like it works if to do cordova platform add https://github.com/apache/cordova-ios

Response:

Warning: using prerelease platform ios@5.2.0-dev. Use ‘cordova platform add ios@latest’ to add the latest published version instead. Adding ios project… Creating Cordova project for the iOS platform: iOS project created with cordova-ios@5.2.0-dev

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use 'WKWebViewOnly' - Apache Cordova
1, I've added ios platform as suggested but I still got the error when I upload to ios store. Is there any way...
Read more >
Getting error while uploading the ionic ios app. Deprecated ...
Step 1: I installed the WKWebView plugin: ionic's. Step 2: Add <preference name="WKWebViewOnly" value="true" /> to your config.xml file. Step ...
Read more >
Cordova-plugin-wkwebview-engine crashes ios build
Hello! Since UIWebView is being deprecated and that cordova ios 6 is still under night builds, I am trying to completely move an...
Read more >
Solved: Add platform iOs cordova plugin iOs failed
Solved: I used to add platform iOs on my Cordova App stable but from yesterday I can't add the platform and the problem...
Read more >
apps for iOS: switching to WKWebView - SAP Blogs
xml to ensure UIWebView is completely removed at compile-time. Ensure cordova ios 5.1.1 or later is used. In config.xml, add < ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found