Hi, I’m developing an Angular + Capacitor app for iOS and I’m trying to use a simple native plugin (like the Echo example) by following the official Capacitor documentation: Capacitor iOS Plugin Guide | Capacitor Documentation
I did not create the plugin as a separate package using npx @capacitor/plugin generate
. Instead, I created the Swift files manually and added them directly inside the iOS project in Xcode, next to AppDelegate.swift
.
My plugin class EchoPlugin
implements CAPPlugin
and CAPBridgedPlugin
, and defines the echo
method properly. I also have an Echo.swift
file that simply returns the value passed to it.
In AppDelegate.swift
, I register the plugin manually with bridge.bridge?.registerPluginInstance(EchoPlugin())
.
In the frontend, I use registerPlugin('Echo')
and call the method using Echo.echo({ value: 'test' })
.
However, the result I get is:
{"code":"UNIMPLEMENTED"}
There’s no output in the Xcode logs, so it seems the native method is never triggered.
Things I already checked:
- The plugin has
@objc
, usesCAPBridgedPlugin
, and definespluginMethods
correctly. - The
jsName
is"Echo"
and matches what I use inregisterPlugin
on the frontend. - I ran
npx cap sync ios
and opened the Xcode project withnpx cap open ios
. - The Swift files are added to the project and are included in the
App
target. - I tried both registering the plugin manually in
AppDelegate.swift
, and letting Capacitor detect it automatically — neither approach worked. - I cleaned the build folder and recompiled the app.
My question is: what am I doing wrong? Is there something specific I need to do if I add Swift plugin files directly into the iOS project, instead of generating a separate plugin package?
Thanks in advance for any help or clarification.