How to add today view extension for a Cordova app for iOS9? [Swift]

813 Views Asked by At

I followed this tutorial for creating a today view extension. It works for a native Xcode 7.3 iOS 9 based app but when I try to follow the same steps for Cordova app. I get build error.

/Users/MAC/Desktop/RWS/RAD/[CORDOVA_APP_NAME]/platforms/ios/[CORDOVA_APP_NAME]/Bridging-Header.h:28:9: note: in file included from /Users/MAC/Desktop/RWS/RAD/[CORDOVA_APP_NAME]/platforms/ios/[CORDOVA_APP_NAME]/Bridging-Header.h:28:
#import <Cordova/CDV.h>
        ^
/Users/MAC/Library/Developer/Xcode/DerivedData/[CORDOVA_APP_NAME]-ggabeceockqrdjbqfzogiakufhxo/Build/Products/Debug-iphonesimulator/include/Cordova/CDV.h:20:9: note: in file included from /Users/MAC/Library/Developer/Xcode/DerivedData/[CORDOVA_APP_NAME]-ggabeceockqrdjbqfzogiakufhxo/Build/Products/Debug-iphonesimulator/include/Cordova/CDV.h:20:
#import "CDVAvailability.h"
        ^
/Users/MAC/Library/Developer/Xcode/DerivedData/[CORDOVA_APP_NAME]-ggabeceockqrdjbqfzogiakufhxo/Build/Products/Debug-iphonesimulator/include/Cordova/CDVAvailability.h:20:9: error: 'CDVAvailabilityDeprecated.h' file not found
#import "CDVAvailabilityDeprecated.h"
        ^
<unknown>:0: error: failed to import bridging header '/Users/MAC/Desktop/RWS/RAD/[CORDOVA_APP_NAME]/platforms/ios/[CORDOVA_APP_NAME]/Bridging-Header.h'
3

There are 3 best solutions below

1
David On BEST ANSWER

I recently solved this by creating a cordova-plugin which adds a (already implemented) today widget to the cordova-ios project: see my answer here

0
Gregory On

I guess that you are using Cordova file plugin. I think It is currently impossible to write today extension with swift language, because this plugin is written in C-objective language and it's not compatible with swift. When I try to add today in C-objective I don't get this error.

0
mahnuh On

I was able to solve the above issues by adding the Foundation.framework and lib.Cordova.a to "Link Binary With Libraries" in the Build Phases. Make sure you select the Today Widget Extension as target when doing so. See the following screenshot: https://i.stack.imgur.com/dSQxG.png