No such module '..Kit' when using Capacitor Plugin

I’m building an Capacitor Plugin. To autenticate a user using WebAuthn (since this is not yet suported in WKWebView-based browsers)

Within this plugin I’m using WebAuthnKit I added it to my Podfile of my plugin. Like so:

...
use_frameworks!
pod 'Capacitor', :path => '../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../node_modules/@capacitor/ios'
pod 'WebAuthnKit', '~> 0.9.5'
...

After running pod install it works great! Also when I build only my plugin using xcode it builds successfully

But then when I use my plugin in my ionic capacitor app (installed locally via npm) xcode spits out the error
No such module 'WebAuthnKit' on the line in the plugin code where I do import WebAuthnKit to use it.

I can fix it by hand but after running ionic cap sync ios all my changes are gone!
What I do to fix it:

  1. Also add pod 'WebAuthnKit', '~> 0.9.5'to my ionic app podfile
  2. Also run pod install in the ios/App folder of my ionic app
  3. Select Pods project from xcode
  4. Select CapacitorMyPlugin from the targets panel to select my plugin
  5. Add WebAuthnKit to the list of Link Binary With Libraries under Build Phases
  6. Add "${PODS_CONFIGURATION_BUILD_DIR}/WebAuthnKit" in the Framework Search Paths (debug and release) under Build Settings

After this is done the error is gone but I have to repeat these steps after every ionic cap sync ios.

Has anyone used external Kits in a Capacitor Plugin?
How do you link the correct pods from xcode workspace?

(opening .xcodeproj or .xcworkspace makes no difference only when opening .xcodeproj it sais No such module ‘Capacitor’)

Hi, I’m having the same problem now, have you solved it now?

You have to add it to both the Podfile and the .podspec.

1 Like

Yeah, as Aparajita mentioned, there are two places where you have to define this dependency. The first, which you’ve done specifies it for the project specific to your plugin, the second, the .podspec file defines it for the consuming application to let it know that it also needs to install this dependency.

Hi, aparajita,

  1. I’m using Google MLKit Translate in my custom capacitor plugin by my podfile(devDependencies):
    target ‘Plugin’ do
    capacitor_pods
    pod ‘GoogleMLKit/Translate’, ‘3.2.0’
    end

  2. And I also added it to the podspec(dependencies):
    s.dependency ‘GoogleMLKit/Translate’, ‘3.2.0’

  3. I still got error message from my target APP(Xcode):
    No such module ‘MLKitTranslate’

Is there anything need to do?
Thank you.

Maybe you can try to add s.static_framework = true

Example:

1 Like

The issue has been solved with your solution.
Thanks for help :slight_smile:

1 Like