Menu

1 / 2

Adding an Apple Watch App or Widget to Cordova

DEV Community·Philipp·6 months ago
#5eBVyuQc
#ios#cordova#ionic#applewatch#discuss
Reading 0:00
15s threshold

Intro

If you want to add native code to Cordova you’re pretty much on your own because the framework won’t help you with it.

Trying to add an iOS 14 widget and an Apple Watch app cost me 2 weeks of digging around in Cordovas source code and figuring out the Xcode project file. This article hopes to save you those 2 weeks.

The method

So obviously the first thing you would try when doing anything that has to do with a native feature in Cordova is you wold look for a plugin that does it for you. Unfortunately the few plugins that exist don’t work anymore. So we need to get our hands dirty ourselves.

The biggest pain point when integrating native features in Cordova is that the Xcode project file is created on every build overwriting any change you did manually.

The birds eye view of what I did is:

Build the Cordova app to generate the Xcode config

Add the iOS 14 widget and the Apple Watch target

See what parts of the Xcode config step 2 changed

Write a script to make those changes on every…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.